@howaboua/pi-durable-sites 0.0.0-stage → 0.10.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.
@@ -0,0 +1,8 @@
1
+ import { type ComponentInstance, type ComponentRequest } from "@howaboua/pi-durable-components";
2
+ import { createSitesExtension, type SitesOptions } from "./index.ts";
3
+ export interface SitesComponentOptions extends SitesOptions {
4
+ fetch: typeof globalThis.fetch;
5
+ }
6
+ /** Grants canonical ChatGPT egress and a project capability for the exact execution namespace. */
7
+ export declare const sitesOptions: import("@howaboua/pi-durable-components").ComponentCapability<SitesComponentOptions>;
8
+ export declare function createComponent(request: ComponentRequest): ComponentInstance<ReturnType<typeof createSitesExtension>>;
@@ -0,0 +1,7 @@
1
+ import type { Context } from "@earendil-works/chord";
2
+ import type { Models } from "@earendil-works/pi-ai";
3
+ /** OAuth resolves through Models, not ambient Pi auth files or model-selected URLs. */
4
+ export declare function getSitesAuth(models: Models, providerId: string, context: Context): Promise<{
5
+ token: string;
6
+ accountId: string;
7
+ }>;
@@ -0,0 +1,36 @@
1
+ export interface JsonSchema {
2
+ [key: string]: unknown;
3
+ properties?: Record<string, unknown>;
4
+ required?: string[];
5
+ }
6
+ export interface SitesClientOptions {
7
+ fetchImpl?: typeof fetch;
8
+ authProvider: () => Promise<{
9
+ token: string;
10
+ accountId: string;
11
+ }>;
12
+ signal?: AbortSignal | undefined;
13
+ }
14
+ interface SitesTool {
15
+ name: string;
16
+ inputSchema?: JsonSchema;
17
+ _meta: Record<string, unknown>;
18
+ }
19
+ export declare class SitesClient {
20
+ private fetchImpl;
21
+ private authProvider;
22
+ private signal;
23
+ private requestId;
24
+ private tools;
25
+ private headers;
26
+ constructor({ fetchImpl, authProvider, signal }: SitesClientOptions);
27
+ initialize(): Promise<void>;
28
+ listSitesTools(): Promise<SitesTool[]>;
29
+ schema(toolSuffix: string): Promise<JsonSchema | undefined>;
30
+ call(toolSuffix: string, args: unknown): Promise<unknown>;
31
+ findTool(toolSuffix: string): Promise<SitesTool>;
32
+ rpc(method: string, params: unknown, { notification }?: {
33
+ notification?: boolean;
34
+ }): Promise<unknown>;
35
+ }
36
+ export {};
@@ -0,0 +1 @@
1
+ export declare const guides: Readonly<Record<string, string>>;
@@ -0,0 +1,2 @@
1
+ import type { SitesClient } from "./client.ts";
2
+ export declare function documentation(input: string | undefined, client: Pick<SitesClient, "schema">): Promise<string>;
@@ -0,0 +1,4 @@
1
+ import type { Context } from "@earendil-works/chord";
2
+ import type { SitesClient } from "./client.ts";
3
+ import type { SitesProjectCapability } from "./local-project.ts";
4
+ export declare function call(request: unknown, client: Pick<SitesClient, "schema" | "call">, cwd: string, projectCapability: SitesProjectCapability, context: Context): Promise<unknown>;
@@ -0,0 +1,146 @@
1
+ import type { Models } from "@earendil-works/pi-ai";
2
+ import type { ExecutionEnv } from "@earendil-works/pi-durable/env";
3
+ import { Type } from "typebox";
4
+ import type { SitesProjectCapability } from "./local-project.ts";
5
+ export type { ProjectContext, SitesProjectCapability, } from "./local-project.ts";
6
+ export { createNativeSitesProjectCapability } from "./native-project.ts";
7
+ export interface SitesOptions {
8
+ models: Models;
9
+ /** Explicit Codex OAuth provider, default openai-codex. Its route must be canonical ChatGPT. */
10
+ providerId?: string;
11
+ /** No host fallback. A returned capability must own the conversation's exact namespace. */
12
+ projectForEnvironment(environment: ExecutionEnv): SitesProjectCapability | undefined;
13
+ /** Host-owned egress, never a configurable backend URL. */
14
+ fetch?: typeof globalThis.fetch;
15
+ }
16
+ export declare const SITES_PARAMETERS: Type.TObject<{
17
+ resource: Type.TOptional<Type.TString>;
18
+ action: Type.TOptional<Type.TString>;
19
+ params: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
20
+ }>;
21
+ export declare const SITES_DOCUMENTATION_PARAMETERS: Type.TObject<{
22
+ topic: Type.TOptional<Type.TString>;
23
+ }>;
24
+ export declare function createSitesTool(options: SitesOptions): {
25
+ name: string;
26
+ description: string;
27
+ parameters: Type.TObject<{
28
+ resource: Type.TOptional<Type.TString>;
29
+ action: Type.TOptional<Type.TString>;
30
+ params: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
31
+ }>;
32
+ constrainedSampling?: false | import("@earendil-works/pi-ai").ConstrainedSamplingConfig;
33
+ replay?: "safe" | "unsafe";
34
+ executionMode?: import("@earendil-works/pi-durable").ToolExecutionMode;
35
+ prepareArguments?(args: unknown): {
36
+ resource?: string;
37
+ action?: string;
38
+ params?: Record<string, unknown>;
39
+ };
40
+ structuredOutputSchema?: Type.TSchema;
41
+ callers?: readonly ("model" | "tools")[];
42
+ deferred?: true;
43
+ outputLimits?: {
44
+ readonly maxBytes?: number;
45
+ readonly maxLines?: number;
46
+ readonly retain?: "head" | "tail";
47
+ };
48
+ execute(args: {
49
+ resource?: string;
50
+ action?: string;
51
+ params?: Record<string, unknown>;
52
+ }, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord").JsonValue>, context: import("@earendil-works/chord").Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord").JsonValue>>;
53
+ executionHints: {
54
+ discovery: "help";
55
+ deferLoading: boolean;
56
+ };
57
+ };
58
+ export declare function createSitesDocumentationTool(options: Pick<SitesOptions, "models" | "providerId" | "fetch">): {
59
+ name: string;
60
+ description: string;
61
+ parameters: Type.TObject<{
62
+ topic: Type.TOptional<Type.TString>;
63
+ }>;
64
+ constrainedSampling?: false | import("@earendil-works/pi-ai").ConstrainedSamplingConfig;
65
+ replay?: "safe" | "unsafe";
66
+ executionMode?: import("@earendil-works/pi-durable").ToolExecutionMode;
67
+ prepareArguments?(args: unknown): {
68
+ topic?: string;
69
+ };
70
+ structuredOutputSchema?: Type.TSchema;
71
+ callers?: readonly ("model" | "tools")[];
72
+ deferred?: true;
73
+ outputLimits?: {
74
+ readonly maxBytes?: number;
75
+ readonly maxLines?: number;
76
+ readonly retain?: "head" | "tail";
77
+ };
78
+ execute(args: {
79
+ topic?: string;
80
+ }, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord").JsonValue>, context: import("@earendil-works/chord").Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord").JsonValue>>;
81
+ executionHints: {
82
+ discovery: "help";
83
+ deferLoading: boolean;
84
+ };
85
+ };
86
+ export declare function createSitesExtension(options: SitesOptions): import("@earendil-works/pi-durable").Extension<{
87
+ name: string;
88
+ description: string;
89
+ parameters: Type.TObject<{
90
+ resource: Type.TOptional<Type.TString>;
91
+ action: Type.TOptional<Type.TString>;
92
+ params: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
93
+ }>;
94
+ constrainedSampling?: false | import("@earendil-works/pi-ai").ConstrainedSamplingConfig;
95
+ replay?: "safe" | "unsafe";
96
+ executionMode?: import("@earendil-works/pi-durable").ToolExecutionMode;
97
+ prepareArguments?(args: unknown): {
98
+ resource?: string;
99
+ action?: string;
100
+ params?: Record<string, unknown>;
101
+ };
102
+ structuredOutputSchema?: Type.TSchema;
103
+ callers?: readonly ("model" | "tools")[];
104
+ deferred?: true;
105
+ outputLimits?: {
106
+ readonly maxBytes?: number;
107
+ readonly maxLines?: number;
108
+ readonly retain?: "head" | "tail";
109
+ };
110
+ execute(args: {
111
+ resource?: string;
112
+ action?: string;
113
+ params?: Record<string, unknown>;
114
+ }, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord").JsonValue>, context: import("@earendil-works/chord").Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord").JsonValue>>;
115
+ executionHints: {
116
+ discovery: "help";
117
+ deferLoading: boolean;
118
+ };
119
+ } | {
120
+ name: string;
121
+ description: string;
122
+ parameters: Type.TObject<{
123
+ topic: Type.TOptional<Type.TString>;
124
+ }>;
125
+ constrainedSampling?: false | import("@earendil-works/pi-ai").ConstrainedSamplingConfig;
126
+ replay?: "safe" | "unsafe";
127
+ executionMode?: import("@earendil-works/pi-durable").ToolExecutionMode;
128
+ prepareArguments?(args: unknown): {
129
+ topic?: string;
130
+ };
131
+ structuredOutputSchema?: Type.TSchema;
132
+ callers?: readonly ("model" | "tools")[];
133
+ deferred?: true;
134
+ outputLimits?: {
135
+ readonly maxBytes?: number;
136
+ readonly maxLines?: number;
137
+ readonly retain?: "head" | "tail";
138
+ };
139
+ execute(args: {
140
+ topic?: string;
141
+ }, api: import("@earendil-works/pi-durable").ToolExecutionApi<import("@earendil-works/chord").JsonValue>, context: import("@earendil-works/chord").Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord").JsonValue>>;
142
+ executionHints: {
143
+ discovery: "help";
144
+ deferLoading: boolean;
145
+ };
146
+ }>;
@@ -0,0 +1,23 @@
1
+ import type { Context } from "@earendil-works/chord";
2
+ export interface ProjectContext {
3
+ root: string;
4
+ manifestPath: string;
5
+ }
6
+ /** Host-authorized filesystem and Git owner for exactly one execution namespace. */
7
+ export interface SitesProjectCapability {
8
+ readonly id: string;
9
+ projectContext(projectDir: unknown, cwd: string, context: Context): Promise<ProjectContext>;
10
+ acquireHostingLock(project: ProjectContext, context: Context): Promise<() => Promise<void>>;
11
+ readHosting(project: ProjectContext, context: Context): Promise<Record<string, unknown>>;
12
+ persistProjectId(project: ProjectContext, projectId: string, context: Context): Promise<void>;
13
+ resolveProjectId(params: Record<string, unknown>, project: ProjectContext, context: Context): Promise<unknown>;
14
+ inspectCleanCommit(project: ProjectContext, context: Context): Promise<{
15
+ root: string;
16
+ commitSha: string;
17
+ }>;
18
+ pushCommit(request: {
19
+ root: string;
20
+ commitSha: string;
21
+ credential: unknown;
22
+ }, context: Context): Promise<void>;
23
+ }
@@ -0,0 +1,11 @@
1
+ import type { Context } from "@earendil-works/chord";
2
+ import type { NodeExecutionEnv } from "@earendil-works/pi-durable/env/node";
3
+ export type RunGit = (cwd: string, args: string[], env?: NodeJS.ProcessEnv, signal?: AbortSignal) => Promise<string>;
4
+ export declare function pushCommit({ root, commitSha, credential, git, signal, }: {
5
+ root: string;
6
+ commitSha: string;
7
+ credential: unknown;
8
+ git: RunGit;
9
+ signal: AbortSignal | undefined;
10
+ }): Promise<void>;
11
+ export declare function gitForContext(environment: NodeExecutionEnv, context: Context): RunGit;
@@ -0,0 +1,4 @@
1
+ import { NodeExecutionEnv } from "@earendil-works/pi-durable/env/node";
2
+ import type { SitesProjectCapability } from "./local-project.ts";
3
+ /** Explicit native capability. Never construct this for a remote or container namespace. */
4
+ export declare function createNativeSitesProjectCapability(environment: NodeExecutionEnv): SitesProjectCapability;
@@ -0,0 +1,19 @@
1
+ interface Operation {
2
+ tool: string;
3
+ topic: string;
4
+ local?: "create" | "save" | "deploy";
5
+ select?: "access";
6
+ }
7
+ export interface ResolvedOperation extends Operation {
8
+ resource: string;
9
+ action: string;
10
+ key: string;
11
+ }
12
+ export declare function resolveOperation(resource: unknown, action: unknown): ResolvedOperation;
13
+ export declare function facadeError(code: string, message: string, topic: string, details?: unknown): Error & {
14
+ code: string;
15
+ topic: string;
16
+ details: unknown;
17
+ };
18
+ export declare function operationForTopic(topic: string): ResolvedOperation | undefined;
19
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function redact(value: unknown): unknown;
2
+ export declare function boundedJson(value: unknown, maxBytes?: number): string;
package/package.json CHANGED
@@ -1,6 +1,66 @@
1
1
  {
2
- "name": "@howaboua/pi-durable-sites",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@howaboua/pi-durable-sites",
3
+ "version": "0.10.0",
4
+ "description": "ChatGPT Sites tools for Pi Durable",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/IgorWarzocha/pi-durable-components.git",
10
+ "directory": "packages/sites"
11
+ },
12
+ "author": "Igor Warzocha",
13
+ "engines": {
14
+ "node": ">=22.19.0"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/packages/sites/src/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/packages/sites/src/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./component": {
24
+ "types": "./dist/packages/sites/src/activation.d.ts",
25
+ "import": "./dist/activation.js"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.md",
31
+ "NOTICE",
32
+ "LICENSE"
33
+ ],
34
+ "sideEffects": false,
35
+ "dependencies": {
36
+ "typebox": "1.3.27",
37
+ "@howaboua/pi-durable-components": "0.10.0"
38
+ },
39
+ "peerDependencies": {
40
+ "@earendil-works/chord": "1.4.0",
41
+ "@earendil-works/pi-ai": "1.4.0",
42
+ "@earendil-works/pi-durable": "1.4.0",
43
+ "@modelcontextprotocol/sdk": ">=1.25.2 <2"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "durable": {
49
+ "schemaVersion": 1,
50
+ "kind": "extension",
51
+ "entry": "./component",
52
+ "runtimes": [
53
+ "node"
54
+ ],
55
+ "requires": [
56
+ "durable.models.v1",
57
+ "durable.network.v1",
58
+ "durable.node-execution.v1"
59
+ ],
60
+ "permissions": [
61
+ "filesystem",
62
+ "network",
63
+ "models"
64
+ ]
65
+ }
66
+ }