@skydiveai/pi-extensions 0.1.0-beta.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Create, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @skydiveai/pi-extensions
2
+
3
+ pi extensions for agent-owned content plus the Skydive platform layer.
4
+
5
+ Extensions (load agent workspace content):
6
+
7
+ - `soulExtension` — soul.md personality
8
+ - `memoryExtension` — .memory/ markdown index
9
+ - `mcpExtension` — mcp.config.json servers, with hot reload and OAuth
10
+ - `localToolsExtension` — tools/\*.ts custom tools, with hot reload
11
+ - `toolCallEnvExtension` — TOOL_CALL_ID env for bash tools
12
+ - `all` — the stock set in load order
13
+ - `platformExtensions({ sessionId, channelContext })` — Skydive-owned:
14
+ daemon session tracking, sandbox heartbeats, OTel self-tracing. Every
15
+ session must include these.
16
+
17
+ Platform layer:
18
+
19
+ - `createHarness` — composes @skydiveai/pi-server's protocol handlers
20
+ with the Skydive defaults (daemon-exported tracing, tool-update
21
+ hot-reload hooks, prewarm paths, proxy header passthrough, agent-card
22
+ branding) into mountable express handlers
23
+ - `createPlatformEnvMiddleware` / `createHealthHandler` — env injection
24
+ from the in-sandbox daemon / e2b envd, and the platform health payload
25
+
26
+ Published to the private Verdaccio registry by the deploy pipeline's
27
+ `publish-system-artifacts` job; the agent harness workspace consumes both
28
+ packages as regular npm dependencies.
@@ -0,0 +1,145 @@
1
+ import { A2AOptions, Middleware, ProtocolsOptions } from "@skydiveai/pi-server";
2
+ import { ExtensionFactory } from "@earendil-works/pi-coding-agent";
3
+ import { Logger } from "pino";
4
+
5
+ //#region src/harness.d.ts
6
+ type CreateHarnessOptions = ProtocolsOptions & {
7
+ cwd: string;
8
+ agentCard?: A2AOptions['agentCard']; /** Merged into the GET /health payload as `metadata`. */
9
+ healthMetadata?: () => Record<string, unknown>;
10
+ };
11
+ declare function createHarness(options: CreateHarnessOptions): {
12
+ platform: {
13
+ handlers: {
14
+ /**
15
+ * Platform health plus the agent's `healthMetadata`. Mount above
16
+ * injectEnv — health must respond immediately for prewarm
17
+ * stashing and readiness probes, and injectEnv can wait up to
18
+ * 10s for env vars during boot.
19
+ */
20
+ health: Middleware; /** Loads platform env (e2b envd / daemon long-poll). */
21
+ injectEnv: Middleware;
22
+ prewarm: Middleware;
23
+ };
24
+ };
25
+ protocols: {
26
+ handlers: {
27
+ /** Express-style; mount at /a2a. */a2a: RequestHandler; /** GET /.well-known/agent-card.json. */
28
+ agentCard: Middleware; /** Mirrors each vendor's API shape. */
29
+ openai: {
30
+ v1: {
31
+ chat: {
32
+ completions: Middleware;
33
+ };
34
+ responses: Middleware;
35
+ };
36
+ };
37
+ anthropic: {
38
+ v1: {
39
+ messages: Middleware;
40
+ };
41
+ };
42
+ /**
43
+ * Everything in one mount: a2a (+ agent card) at their well-known
44
+ * paths, then chat-completions / anthropic-messages / responses.
45
+ * Calls next() when nothing matches.
46
+ */
47
+ all: Middleware;
48
+ };
49
+ };
50
+ };
51
+ //#endregion
52
+ //#region src/platform-middleware.d.ts
53
+ /**
54
+ * Middleware that loads platform config (e2b envd / daemon env) before
55
+ * requests reach the protocol handlers. Builds a headers-only Request —
56
+ * the body stream must stay untouched for the downstream handlers.
57
+ * Mount above everything except /health; it can wait up to 10s for env
58
+ * vars during boot.
59
+ */
60
+ declare function createPlatformEnvMiddleware(): Middleware;
61
+ /**
62
+ * GET /health handler: platform health data plus whatever the agent's
63
+ * `metadata` callback returns. Must respond immediately (readiness
64
+ * probes, prewarm stashing) — mount it above the platform env
65
+ * middleware.
66
+ */
67
+ declare function createHealthHandler({
68
+ metadata
69
+ }: {
70
+ metadata: (() => Record<string, unknown>) | null;
71
+ }): Middleware;
72
+ //#endregion
73
+ //#region src/platform-env-middleware.d.ts
74
+ declare function isPlatformConfigLoaded(): boolean;
75
+ declare function loadPlatformConfig(request: Request): Promise<void>;
76
+ //#endregion
77
+ //#region src/extensions/local-tools.d.ts
78
+ declare const localToolsExtension: ExtensionFactory;
79
+ //#endregion
80
+ //#region src/extensions/mcp/index.d.ts
81
+ declare const _default: ExtensionFactory;
82
+ //#endregion
83
+ //#region src/extensions/memory.d.ts
84
+ declare const memoryExtension: ExtensionFactory;
85
+ //#endregion
86
+ //#region src/extensions/soul.d.ts
87
+ declare const soulExtension: ExtensionFactory;
88
+ //#endregion
89
+ //#region src/extensions/tool-call-env.d.ts
90
+ declare const toolCallEnvExtension: ExtensionFactory;
91
+ //#endregion
92
+ //#region src/extensions/index.d.ts
93
+ /**
94
+ * The static (config-free) agent extensions, in load order. `memoryExtension`
95
+ * is the generic, agent-owned slice (`projects/`/`feedback/`/`reference/`); the
96
+ * per-user `users/` slice is rendered by the platform memory extension inside
97
+ * `platformExtensions()`, which can resolve the current user.
98
+ */
99
+ declare const all: ExtensionFactory[];
100
+ /**
101
+ * Platform-owned extensions — daemon session tracking, sandbox heartbeats,
102
+ * OTel self-tracing, and background tasks. These are platform capabilities
103
+ * every session must include (not agent-authored content); the session
104
+ * factory appends them to the agent-chosen set.
105
+ */
106
+ declare function platformExtensions({
107
+ sessionId,
108
+ channelContext
109
+ }: {
110
+ sessionId: string;
111
+ channelContext: string | null;
112
+ }): ExtensionFactory[];
113
+ //#endregion
114
+ //#region src/tool-update-loop.d.ts
115
+ type SessionLike = {
116
+ reload: () => Promise<void>;
117
+ bindExtensions: (vars: Record<string, unknown>) => Promise<void>;
118
+ sendCustomMessage: (msg: {
119
+ customType: string;
120
+ content: string;
121
+ display: boolean;
122
+ details: Record<string, unknown>;
123
+ }, options: {
124
+ triggerTurn: boolean;
125
+ }) => Promise<void>;
126
+ };
127
+ type SessionWithAgent = {
128
+ agent: unknown;
129
+ } & SessionLike;
130
+ declare function installToolUpdateAutoStop({
131
+ session,
132
+ log
133
+ }: {
134
+ session: SessionWithAgent;
135
+ log: Logger;
136
+ }): void;
137
+ declare function runToolUpdateLoop({
138
+ session,
139
+ log
140
+ }: {
141
+ session: SessionLike;
142
+ log: Logger;
143
+ }): Promise<void>;
144
+ //#endregion
145
+ export { type CreateHarnessOptions, all, createHarness, createHealthHandler, createPlatformEnvMiddleware, installToolUpdateAutoStop, isPlatformConfigLoaded, loadPlatformConfig, localToolsExtension, _default as mcpExtension, memoryExtension, platformExtensions, runToolUpdateLoop, soulExtension, toolCallEnvExtension };