@fastagent-sh/fastagent 0.19.0 → 0.20.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/atomic-write.d.ts +11 -7
- package/dist/atomic-write.js +16 -11
- package/dist/channels/agentcore-limits.d.ts +9 -0
- package/dist/channels/agentcore-limits.js +9 -0
- package/dist/channels/agentcore-service.d.ts +12 -11
- package/dist/channels/agentcore-service.js +14 -18
- package/dist/channels/agentcore.d.ts +11 -19
- package/dist/channels/agentcore.js +14 -7
- package/dist/channels/control.d.ts +50 -12
- package/dist/channels/control.js +239 -96
- package/dist/channels/discover.d.ts +26 -4
- package/dist/channels/discover.js +12 -23
- package/dist/channels/feishu/feishu-api.js +5 -8
- package/dist/channels/feishu/feishu.js +35 -18
- package/dist/channels/kit/attachment-path.d.ts +12 -0
- package/dist/channels/kit/attachment-path.js +43 -0
- package/dist/channels/kit/context-buffer.d.ts +9 -0
- package/dist/channels/kit/context-buffer.js +11 -0
- package/dist/channels/kit/signature.d.ts +12 -0
- package/dist/channels/kit/signature.js +17 -0
- package/dist/channels/kit/stop-command.js +3 -3
- package/dist/channels/kit/tasks.d.ts +1 -1
- package/dist/channels/kit/tasks.js +10 -4
- package/dist/channels/kit/turn-store.d.ts +19 -3
- package/dist/channels/kit/turn-store.js +29 -2
- package/dist/channels/slack/invoke-turn.d.ts +1 -1
- package/dist/channels/slack/invoke-turn.js +5 -1
- package/dist/channels/slack/onboard.js +5 -5
- package/dist/channels/slack/onboarding-state.d.ts +7 -3
- package/dist/channels/slack/onboarding-state.js +13 -20
- package/dist/channels/slack/register-webhook.js +1 -1
- package/dist/channels/slack/scaffold/slack-send.ts +2 -17
- package/dist/channels/slack/slack-api.js +22 -54
- package/dist/channels/slack/slack.js +13 -13
- package/dist/channels/telegram/parse.d.ts +21 -1
- package/dist/channels/telegram/parse.js +65 -11
- package/dist/channels/telegram/scaffold/channel.ts +7 -3
- package/dist/channels/telegram/telegram-api.js +5 -6
- package/dist/channels/telegram/telegram.d.ts +2 -2
- package/dist/channels/telegram/telegram.js +57 -69
- package/dist/cli/add-slack.js +6 -5
- package/dist/cli/commands/add.js +1 -5
- package/dist/cli/commands/attach.d.ts +2 -4
- package/dist/cli/commands/attach.js +17 -15
- package/dist/cli/commands/deploy.d.ts +50 -5
- package/dist/cli/commands/deploy.js +183 -134
- package/dist/cli/commands/dev.js +4 -31
- package/dist/cli/commands/info.js +1 -2
- package/dist/cli/commands/init.js +1 -2
- package/dist/cli/commands/start.js +31 -41
- package/dist/cli/serve.d.ts +12 -21
- package/dist/cli/serve.js +20 -25
- package/dist/cli/shared.d.ts +40 -10
- package/dist/cli/shared.js +51 -4
- package/dist/deploy/agentcore/logs.d.ts +2 -2
- package/dist/deploy/agentcore/logs.js +2 -2
- package/dist/deploy/agentcore/plan.d.ts +12 -10
- package/dist/deploy/agentcore/plan.js +39 -31
- package/dist/deploy/agentcore/run.d.ts +5 -4
- package/dist/deploy/agentcore/run.js +13 -36
- package/dist/deploy/channel-ingress.d.ts +73 -0
- package/dist/deploy/channel-ingress.js +101 -0
- package/dist/deploy/docker/plan.d.ts +3 -7
- package/dist/deploy/docker/plan.js +4 -15
- package/dist/deploy/docker/run.d.ts +18 -1
- package/dist/deploy/docker/run.js +10 -0
- package/dist/deploy/fly/plan.d.ts +4 -5
- package/dist/deploy/fly/plan.js +7 -22
- package/dist/deploy/fly/run.d.ts +9 -23
- package/dist/deploy/fly/run.js +32 -68
- package/dist/deploy/preflight.d.ts +6 -7
- package/dist/deploy/preflight.js +26 -22
- package/dist/deploy/railway/plan.d.ts +4 -5
- package/dist/deploy/railway/plan.js +11 -26
- package/dist/deploy/railway/run.d.ts +9 -9
- package/dist/deploy/railway/run.js +40 -40
- package/dist/deploy/runner.js +22 -2
- package/dist/deploy/secrets.d.ts +18 -9
- package/dist/deploy/secrets.js +64 -12
- package/dist/dev-supervisor.js +3 -4
- package/dist/engines/pi/agent-session-factory.js +20 -39
- package/dist/engines/pi/auth.js +43 -43
- package/dist/engines/pi/config.d.ts +1 -1
- package/dist/engines/pi/create.d.ts +14 -2
- package/dist/engines/pi/create.js +2 -2
- package/dist/engines/pi/definition.d.ts +1 -1
- package/dist/engines/pi/definition.js +3 -4
- package/dist/engines/pi/login.js +32 -16
- package/dist/engines/pi/open.d.ts +1 -2
- package/dist/engines/pi/open.js +1 -1
- package/dist/engines/pi/search-tools.js +1 -1
- package/dist/engines/pi/service.d.ts +1 -1
- package/dist/engines/pi/service.js +8 -0
- package/dist/engines/pi/session-builder.js +6 -33
- package/dist/engines/pi/session-control.d.ts +19 -6
- package/dist/engines/pi/session-control.js +565 -470
- package/dist/engines/pi/session-inheritance.d.ts +8 -22
- package/dist/engines/pi/session-inheritance.js +95 -76
- package/dist/engines/pi/session-markers.d.ts +48 -0
- package/dist/engines/pi/session-markers.js +59 -0
- package/dist/engines/pi/session-settings.d.ts +4 -4
- package/dist/engines/pi/session-settings.js +7 -4
- package/dist/engines/pi/session-store.d.ts +83 -13
- package/dist/engines/pi/session-store.js +408 -55
- package/dist/engines/pi/tool-context.d.ts +21 -8
- package/dist/engines/pi/tool-context.js +29 -4
- package/dist/engines/pi/tool.js +2 -2
- package/dist/env.js +1 -2
- package/dist/loader.d.ts +49 -7
- package/dist/loader.js +79 -18
- package/dist/paths.d.ts +19 -0
- package/dist/paths.js +27 -2
- package/dist/scaffold/add-channel.js +2 -2
- package/dist/scaffold/init.js +7 -2
- package/dist/scaffold/templates/tools/fetch-url.ts +0 -2
- package/dist/schedule/discover.js +3 -15
- package/dist/schedule/wake-alarm.d.ts +13 -7
- package/dist/schedule/wake-alarm.js +88 -46
- package/dist/schedule/wakeups.d.ts +1 -1
- package/dist/schedule/wakeups.js +10 -7
- package/dist/service.d.ts +1 -2
- package/dist/service.js +27 -5
- package/dist/session-remote.d.ts +7 -2
- package/dist/session-remote.js +162 -92
- package/dist/session.d.ts +226 -92
- package/dist/session.js +61 -23
- package/dist/telegram.d.ts +1 -1
- package/dist/telegram.js +1 -1
- package/dist/tunnel.d.ts +18 -3
- package/dist/tunnel.js +32 -40
- package/package.json +1 -1
|
@@ -36,10 +36,9 @@ import { resolveModel } from "./config.js";
|
|
|
36
36
|
import { assembleSystemPrompt, piBasePrompt } from "./create.js";
|
|
37
37
|
import { canonicalPath, loadAgentDefinition, loadExtensionPaths } from "./definition.js";
|
|
38
38
|
import { createPiModelRuntime, probeAuthSource } from "./models.js";
|
|
39
|
-
import { log } from "../../log.js";
|
|
40
|
-
import {
|
|
39
|
+
import { log, reportModuleLoadFailures } from "../../log.js";
|
|
40
|
+
import { agentSessionManager, sessionToolActivation, turnContext, } from "./tool-context.js";
|
|
41
41
|
import { reportFindingsIfChanged, reportToolCollisions } from "./report.js";
|
|
42
|
-
import { reportModuleLoadFailures } from "../../log.js";
|
|
43
42
|
import { resolveAgentAssembly } from "./open.js";
|
|
44
43
|
/**
|
|
45
44
|
* Build pi's interactive runtime driven by fastagent's assembled agent (model, prompt, tools,
|
|
@@ -49,34 +48,6 @@ import { resolveAgentAssembly } from "./open.js";
|
|
|
49
48
|
export async function buildAgentSessionRuntime(dir, options = {},
|
|
50
49
|
/** Session backend. Defaults to pi's project-scoped store; tests inject SessionManager.inMemory(). */
|
|
51
50
|
sessionManager) {
|
|
52
|
-
/** The turn's {@link ToolActivation} over pi's AgentSession — the counterpart of invoke.ts's
|
|
53
|
-
* serving bridge, so the SAME builtin search_tools serves both paths. Additive; unknown names
|
|
54
|
-
* filtered (`setActiveToolsByName` is authoritative on the session and rebuilds its prompt — our
|
|
55
|
-
* static override keeps the prompt identical to serving). */
|
|
56
|
-
function sessionToolActivation(session) {
|
|
57
|
-
// Same serialization as invoke.ts's bridge (there per turn; here per session — interactive turns
|
|
58
|
-
// make per-session equivalent): the read-modify-write below is only race-free while nothing awaits
|
|
59
|
-
// between read and write, and pi's session setters happening to be synchronous today is not a
|
|
60
|
-
// contract worth betting parallel tool batches on. Built ONCE per session (createRuntime), so
|
|
61
|
-
// parallel calls actually share the chain.
|
|
62
|
-
let chain = Promise.resolve([]);
|
|
63
|
-
return {
|
|
64
|
-
active: () => session.getActiveToolNames(),
|
|
65
|
-
registered: () => session.getAllTools().map((t) => ({ name: t.name, description: t.description ?? "" })),
|
|
66
|
-
activate(names) {
|
|
67
|
-
const run = async () => {
|
|
68
|
-
const current = session.getActiveToolNames();
|
|
69
|
-
const added = additiveActivation(session.getAllTools().map((t) => t.name), current, names);
|
|
70
|
-
if (added.length > 0)
|
|
71
|
-
session.setActiveToolsByName([...current, ...added]);
|
|
72
|
-
return added;
|
|
73
|
-
};
|
|
74
|
-
const result = chain.then(run, run); // run after the predecessor settles, success or failure
|
|
75
|
-
chain = result.catch(() => []); // the caller sees a rejection on `result`; the chain stays usable
|
|
76
|
-
return result;
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
51
|
async function resolveAssembly(cwd) {
|
|
81
52
|
// The shared front half — the SAME placement/config/model-spec/tool/auth resolution the serving
|
|
82
53
|
// opener uses (open.ts); those inputs cannot drift between the two consumption shapes.
|
|
@@ -154,11 +125,13 @@ sessionManager) {
|
|
|
154
125
|
// would leak env or require mutating global env at runtime.
|
|
155
126
|
const rootCwd = canonicalPath(dir);
|
|
156
127
|
// The CURRENT pi session + its activation bridge, BOUND TOGETHER — rebuilt on /new//resume/fork
|
|
157
|
-
// while the memoized assembly (and its tool execute closures) stays. The bridge
|
|
158
|
-
// session's lifetime
|
|
128
|
+
// while the memoized assembly (and its tool execute closures) stays. The bridge shares the
|
|
129
|
+
// session's lifetime because a tool call has to see what the previous one activated. Note on
|
|
159
130
|
// parallel batches: pi wraps SDK customTools in its own before/after active-set diff, so an
|
|
160
131
|
// activating tool must carry `executionMode: "sequential"` (the builtin loader does) — pi then runs
|
|
161
132
|
// the whole batch serially and the outer diff sees correct snapshots.
|
|
133
|
+
// NO activation record here: pi's chat session has nowhere to put one (see sessionToolActivation's
|
|
134
|
+
// `onActivated`), which is the documented divergence from serving — a resumed chat re-discovers.
|
|
162
135
|
const sessionRef = {};
|
|
163
136
|
let assembly;
|
|
164
137
|
const assemblyFor = (cwd) => {
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The pi implementation of the session control plane. `createPiSessionControl` returns the neutral
|
|
3
|
+
* `SessionControl` plus the {@link SessionObserver} to plug into the invoke pipeline
|
|
4
|
+
* (`createPiAgent({ observer })`).
|
|
5
|
+
*
|
|
6
|
+
* It holds no durable state of its own: live truth comes from the event stream (plus the
|
|
7
|
+
* {@link RunControls} a `run_started` carries), durable truth from {@link PiSessionRecordStore} —
|
|
8
|
+
* which is also what performs every write, so how a record takes a property is not knowledge this
|
|
9
|
+
* file has. What it owns is the vocabulary: capability gating, the lease, error codes, and the
|
|
10
|
+
* events its own writes emit.
|
|
11
|
+
*
|
|
12
|
+
* Writes take the same lease as runs. Without boundary wiring they reject before acceptance with
|
|
13
|
+
* `unsupported_capability` — a client gating on `capabilities()` never sends them.
|
|
14
|
+
*/
|
|
15
|
+
import { type ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
16
|
+
import { type Models } from "@earendil-works/pi-ai";
|
|
3
17
|
import { type AgentCommand, type SessionControl, type SessionEvent } from "../../session.ts";
|
|
4
|
-
import type { SessionObserver } from "./turn-kit.ts";
|
|
5
|
-
import type { Lease } from "./turn-kit.ts";
|
|
18
|
+
import type { SessionObserver, Lease } from "./turn-kit.ts";
|
|
6
19
|
import type { AnyModel } from "./models.ts";
|
|
7
20
|
import type { PiAgentSessionFactory } from "./invoke-session.ts";
|
|
8
21
|
import type { PiSessionRecordStore } from "./session-store.ts";
|
|
@@ -15,8 +28,8 @@ import type { PiSessionRecordStore } from "./session-store.ts";
|
|
|
15
28
|
* permanently stalled one holds the frozen buffer until its TCP connection dies. Recovery either
|
|
16
29
|
* way is the standard reconnect+backfill, semantically lossless. */
|
|
17
30
|
export declare const SUBSCRIBER_BUFFER_CAP = 10000;
|
|
18
|
-
/** What
|
|
19
|
-
* agent assembly uses: the lease (
|
|
31
|
+
/** What the plane's writes (`update` / `compact` / `fork` / `delete`) need — the SAME instances the
|
|
32
|
+
* agent assembly uses: the lease (a write must not race a run), the model registry (validation +
|
|
20
33
|
* allowedModels), and the session factory (compaction is a model call). Writes go through the
|
|
21
34
|
* record the hub's reader opened — after an existence check, so the control plane never creates
|
|
22
35
|
* a session (that is the data plane's monopoly). */
|