@skydiveai/pi-extensions 0.1.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/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,163 @@
1
+ /// <reference types="node" />
2
+ import { A2AOptions, Middleware, ProtocolsOptions } from "@skydiveai/pi-server";
3
+ import { ExtensionFactory } from "@earendil-works/pi-coding-agent";
4
+ import * as _$qs from "qs";
5
+ import * as _$express from "express";
6
+ import { Logger } from "pino";
7
+
8
+ //#region ../../node_modules/@types/express-serve-static-core/index.d.ts
9
+ declare global {
10
+ namespace Express {
11
+ // These open interfaces may be extended in an application-specific manner via declaration merging.
12
+ // See for example method-override.d.ts (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/method-override/index.d.ts)
13
+ interface Request {}
14
+ interface Response {}
15
+ interface Locals {}
16
+ interface Application {}
17
+ }
18
+ }
19
+ interface ParamsDictionary {
20
+ [key: string]: string;
21
+ }
22
+ //#endregion
23
+ //#region src/harness.d.ts
24
+ type CreateHarnessOptions = ProtocolsOptions & {
25
+ cwd: string;
26
+ agentCard?: A2AOptions['agentCard']; /** Merged into the GET /health payload as `metadata`. */
27
+ healthMetadata?: () => Record<string, unknown>;
28
+ };
29
+ declare function createHarness(options: CreateHarnessOptions): {
30
+ platform: {
31
+ handlers: {
32
+ /**
33
+ * Platform health plus the agent's `healthMetadata`. Mount above
34
+ * injectEnv — health must respond immediately for prewarm
35
+ * stashing and readiness probes, and injectEnv can wait up to
36
+ * 10s for env vars during boot.
37
+ */
38
+ health: Middleware; /** Loads platform env (e2b envd / daemon long-poll). */
39
+ injectEnv: Middleware;
40
+ prewarm: Middleware;
41
+ };
42
+ };
43
+ protocols: {
44
+ handlers: {
45
+ /** Express-style; mount at /a2a. */a2a: _$express.RequestHandler<ParamsDictionary, any, any, _$qs.ParsedQs, Record<string, any>>; /** GET /.well-known/agent-card.json. */
46
+ agentCard: Middleware; /** Mirrors each vendor's API shape. */
47
+ openai: {
48
+ v1: {
49
+ chat: {
50
+ completions: Middleware;
51
+ };
52
+ responses: Middleware;
53
+ };
54
+ };
55
+ anthropic: {
56
+ v1: {
57
+ messages: Middleware;
58
+ };
59
+ };
60
+ /**
61
+ * Everything in one mount: a2a (+ agent card) at their well-known
62
+ * paths, then chat-completions / anthropic-messages / responses.
63
+ * Calls next() when nothing matches.
64
+ */
65
+ all: Middleware;
66
+ };
67
+ };
68
+ };
69
+ //#endregion
70
+ //#region src/platform-middleware.d.ts
71
+ /**
72
+ * Middleware that loads platform config (e2b envd / daemon env) before
73
+ * requests reach the protocol handlers. Builds a headers-only Request —
74
+ * the body stream must stay untouched for the downstream handlers.
75
+ * Mount above everything except /health; it can wait up to 10s for env
76
+ * vars during boot.
77
+ */
78
+ declare function createPlatformEnvMiddleware(): Middleware;
79
+ /**
80
+ * GET /health handler: platform health data plus whatever the agent's
81
+ * `metadata` callback returns. Must respond immediately (readiness
82
+ * probes, prewarm stashing) — mount it above the platform env
83
+ * middleware.
84
+ */
85
+ declare function createHealthHandler({
86
+ metadata
87
+ }: {
88
+ metadata: (() => Record<string, unknown>) | null;
89
+ }): Middleware;
90
+ //#endregion
91
+ //#region src/platform-env-middleware.d.ts
92
+ declare function isPlatformConfigLoaded(): boolean;
93
+ declare function loadPlatformConfig(request: Request): Promise<void>;
94
+ //#endregion
95
+ //#region src/extensions/local-tools.d.ts
96
+ declare const localToolsExtension: ExtensionFactory;
97
+ //#endregion
98
+ //#region src/extensions/mcp/index.d.ts
99
+ declare const _default: ExtensionFactory;
100
+ //#endregion
101
+ //#region src/extensions/memory.d.ts
102
+ declare const memoryExtension: ExtensionFactory;
103
+ //#endregion
104
+ //#region src/extensions/soul.d.ts
105
+ declare const soulExtension: ExtensionFactory;
106
+ //#endregion
107
+ //#region src/extensions/tool-call-env.d.ts
108
+ declare const toolCallEnvExtension: ExtensionFactory;
109
+ //#endregion
110
+ //#region src/extensions/index.d.ts
111
+ /**
112
+ * The static (config-free) agent extensions, in load order. `memoryExtension`
113
+ * is the generic, agent-owned slice (`projects/`/`feedback/`/`reference/`); the
114
+ * per-user `users/` slice is rendered by the platform memory extension inside
115
+ * `platformExtensions()`, which can resolve the current user.
116
+ */
117
+ declare const all: ExtensionFactory[];
118
+ /**
119
+ * Platform-owned extensions — daemon session tracking, sandbox heartbeats,
120
+ * OTel self-tracing, and background tasks. These are platform capabilities
121
+ * every session must include (not agent-authored content); the session
122
+ * factory appends them to the agent-chosen set.
123
+ */
124
+ declare function platformExtensions({
125
+ sessionId,
126
+ channelContext
127
+ }: {
128
+ sessionId: string;
129
+ channelContext: string | null;
130
+ }): ExtensionFactory[];
131
+ //#endregion
132
+ //#region src/tool-update-loop.d.ts
133
+ type SessionLike = {
134
+ reload: () => Promise<void>;
135
+ bindExtensions: (vars: Record<string, unknown>) => Promise<void>;
136
+ sendCustomMessage: (msg: {
137
+ customType: string;
138
+ content: string;
139
+ display: boolean;
140
+ details: Record<string, unknown>;
141
+ }, options: {
142
+ triggerTurn: boolean;
143
+ }) => Promise<void>;
144
+ };
145
+ type SessionWithAgent = {
146
+ agent: unknown;
147
+ } & SessionLike;
148
+ declare function installToolUpdateAutoStop({
149
+ session,
150
+ log
151
+ }: {
152
+ session: SessionWithAgent;
153
+ log: Logger;
154
+ }): void;
155
+ declare function runToolUpdateLoop({
156
+ session,
157
+ log
158
+ }: {
159
+ session: SessionLike;
160
+ log: Logger;
161
+ }): Promise<void>;
162
+ //#endregion
163
+ export { type CreateHarnessOptions, all, createHarness, createHealthHandler, createPlatformEnvMiddleware, installToolUpdateAutoStop, isPlatformConfigLoaded, loadPlatformConfig, localToolsExtension, _default as mcpExtension, memoryExtension, platformExtensions, runToolUpdateLoop, soulExtension, toolCallEnvExtension };