@howaboua/pi-chatgpt-sites 0.0.1 → 0.0.3
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/CHANGELOG.md +10 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +66 -16
- package/dist/src/docs/deployment.md +7 -8
- package/dist/src/docs/domains.md +0 -1
- package/dist/src/docs/environment.md +10 -10
- package/dist/src/docs/index.md +12 -12
- package/dist/src/docs/workflow.md +0 -1
- package/dist/src/facade.d.ts +1 -5
- package/dist/src/facade.js +1 -5
- package/package.json +11 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @howaboua/pi-chatgpt-sites
|
|
2
2
|
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
- - Sites calls now return their payload directly instead of an outer `result` wrapper.
|
|
6
|
+
- Errors show the problem and recovery information without diagnostic envelopes.
|
|
7
|
+
- GPT mode uses note-style guide and schema discovery.
|
|
8
|
+
|
|
9
|
+
## 0.0.2
|
|
10
|
+
|
|
11
|
+
- Streamlined tool descriptions and on-demand help discovery. Guide contents are unchanged.
|
|
12
|
+
|
|
3
13
|
## 0.0.1
|
|
4
14
|
|
|
5
15
|
- ### Features
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export default function sitesExtension(pi: ExtensionAPI): void
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
export default function sitesExtension(pi: ExtensionAPI): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
1
2
|
import { Type } from "typebox";
|
|
2
3
|
import { getSitesAuth } from "./src/auth.js";
|
|
3
4
|
import { SitesClient } from "./src/client.js";
|
|
4
5
|
import { call, documentation } from "./src/facade.js";
|
|
5
|
-
import { boundedJson } from "./src/redact.js";
|
|
6
|
+
import { boundedJson, redact } from "./src/redact.js";
|
|
6
7
|
async function result(run) {
|
|
7
8
|
try {
|
|
8
9
|
const value = await run();
|
|
@@ -20,27 +21,32 @@ async function result(run) {
|
|
|
20
21
|
}
|
|
21
22
|
catch (error) {
|
|
22
23
|
const info = error instanceof Error ? error : new Error(String(error));
|
|
23
|
-
throw new Error(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
throw new Error([
|
|
25
|
+
redact(info.message),
|
|
26
|
+
"topic" in info &&
|
|
27
|
+
info.topic &&
|
|
28
|
+
!info.message.includes("sites_documentation(")
|
|
29
|
+
? `See sites_documentation({topic:${JSON.stringify(info.topic)}})`
|
|
30
|
+
: undefined,
|
|
31
|
+
"termsUrl" in info && info.termsUrl
|
|
32
|
+
? `Terms: ${redact(info.termsUrl)}`
|
|
33
|
+
: undefined,
|
|
34
|
+
"details" in info && info.details
|
|
35
|
+
? boundedJson(info.details)
|
|
36
|
+
: undefined,
|
|
37
|
+
]
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.join("\n"));
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
function isRecord(value) {
|
|
37
43
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
38
44
|
}
|
|
39
|
-
export default function sitesExtension(pi) {
|
|
40
|
-
|
|
45
|
+
export default async function sitesExtension(pi) {
|
|
46
|
+
const sites = defineTool({
|
|
41
47
|
name: "sites",
|
|
42
48
|
label: "Sites",
|
|
43
|
-
description: "Manage ChatGPT Sites
|
|
49
|
+
description: "Manage ChatGPT Sites",
|
|
44
50
|
parameters: Type.Object({
|
|
45
51
|
resource: Type.Optional(Type.String()),
|
|
46
52
|
action: Type.Optional(Type.String()),
|
|
@@ -56,7 +62,7 @@ export default function sitesExtension(pi) {
|
|
|
56
62
|
: call(args, client, ctx.cwd, signal));
|
|
57
63
|
},
|
|
58
64
|
});
|
|
59
|
-
|
|
65
|
+
const guide = defineTool({
|
|
60
66
|
name: "sites_documentation",
|
|
61
67
|
label: "Sites documentation",
|
|
62
68
|
description: "Sites guide or current resource.action parameter schema",
|
|
@@ -65,4 +71,48 @@ export default function sitesExtension(pi) {
|
|
|
65
71
|
return result(() => documentation(args.topic === "help" ? "index" : args.topic, new SitesClient({ authProvider: () => getSitesAuth(ctx), signal })));
|
|
66
72
|
},
|
|
67
73
|
});
|
|
74
|
+
const tools = [
|
|
75
|
+
{
|
|
76
|
+
tool: sites,
|
|
77
|
+
gpt: "Manage ChatGPT Sites",
|
|
78
|
+
ordinary: sites.description,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
tool: guide,
|
|
82
|
+
gpt: "Sites guide/live resource.action parameter schema",
|
|
83
|
+
ordinary: guide.description,
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
for (const { tool } of tools)
|
|
87
|
+
pi.registerTool(tool);
|
|
88
|
+
try {
|
|
89
|
+
const { adaptToolForCodeMode, registerCodeModeExtensionTools } = await import("@howaboua/pi-codex-conversion/code-mode");
|
|
90
|
+
const registration = registerCodeModeExtensionTools(pi, () => tools.map(({ tool }) => adaptToolForCodeMode(tool, {
|
|
91
|
+
discovery: "help",
|
|
92
|
+
deferLoading: true,
|
|
93
|
+
})));
|
|
94
|
+
pi.on("session_shutdown", () => registration.unregister());
|
|
95
|
+
const { registerGptPromptMode } = await import("@howaboua/pi-codex-conversion/prompt-mode");
|
|
96
|
+
registerGptPromptMode(pi, (active) => {
|
|
97
|
+
for (const { tool, gpt, ordinary } of tools) {
|
|
98
|
+
const description = active ? gpt : ordinary;
|
|
99
|
+
if (tool.description !== description) {
|
|
100
|
+
tool.description = description;
|
|
101
|
+
pi.registerTool(tool);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return tools.map(({ tool }) => tool);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (!(error instanceof Error) ||
|
|
109
|
+
!("code" in error) ||
|
|
110
|
+
![
|
|
111
|
+
"ERR_MODULE_NOT_FOUND",
|
|
112
|
+
"MODULE_NOT_FOUND",
|
|
113
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
114
|
+
].includes(String(error.code)) ||
|
|
115
|
+
!error.message.includes("@howaboua/pi-codex-conversion"))
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
68
118
|
}
|
|
@@ -5,7 +5,6 @@ Every Sites deployment URL is production. Deploy only a saved `version_id` withi
|
|
|
5
5
|
## `deployment.deploy`
|
|
6
6
|
|
|
7
7
|
Required facade parameters: `project_id` (or local manifest), `version_id`, and `visibility`.
|
|
8
|
-
|
|
9
8
|
- `visibility: "private"` uses the owner-only deployment path. The backend refuses it unless the caller is the sole explicitly allowed viewer and no groups are allowed.
|
|
10
9
|
- `visibility: "shared"` is an open-world production deployment for shared, workspace, public, or unverifiable access.
|
|
11
10
|
|
|
@@ -13,13 +12,13 @@ Calling this action is the production effect. Preserve the existing audience unl
|
|
|
13
12
|
|
|
14
13
|
```js
|
|
15
14
|
await tools.sites({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
15
|
+
resource: "deployment",
|
|
16
|
+
action: "deploy",
|
|
17
|
+
params: {
|
|
18
|
+
version_id: "<opaque-version-id>",
|
|
19
|
+
visibility: "private",
|
|
20
|
+
},
|
|
21
|
+
});
|
|
23
22
|
```
|
|
24
23
|
|
|
25
24
|
If private deployment is rejected because access is not owner-only, reread `site.get`. Never silently fall back or alter access. Report any conflict with the requested audience.
|
package/dist/src/docs/domains.md
CHANGED
|
@@ -10,7 +10,6 @@ Use resource name `domain` in calls. Sites does not register domains; the user m
|
|
|
10
10
|
- `domain.remove`: immediately detach the exact custom domain. Pi custom tools have no separate approval callback.
|
|
11
11
|
|
|
12
12
|
Typical flow:
|
|
13
|
-
|
|
14
13
|
1. Add the apex domain or subdomain.
|
|
15
14
|
2. Show the returned DNS names, record types, and values to the user.
|
|
16
15
|
3. Wait for the user to update DNS at their provider.
|
|
@@ -12,16 +12,16 @@ Pass `set_values` and optional `remove`:
|
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
14
|
await tools.sites({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
15
|
+
resource: "environment",
|
|
16
|
+
action: "update",
|
|
17
|
+
params: {
|
|
18
|
+
set_values: [
|
|
19
|
+
{ key: "API_ORIGIN", value: "https://example.test", is_secret: false },
|
|
20
|
+
{ key: "SERVICE_TOKEN", value: "<secret>", is_secret: true },
|
|
21
|
+
],
|
|
22
|
+
remove: [],
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Keys are case-sensitive. Do not repeat a key or put it in both lists. Only listed keys change. Mark sensitive values with `is_secret: true` and do not echo them in prose or logs. The tool deliberately cannot read values from arbitrary environment variables or files. For secrets that should never enter model context, use the Sites settings UI instead.
|
package/dist/src/docs/index.md
CHANGED
|
@@ -4,17 +4,17 @@ Private beta API. Read `workflow`, then the relevant topic. `resource.action` re
|
|
|
4
4
|
|
|
5
5
|
Call `sites` with `{resource, action, params}`. Omitted `project_id` uses `.openai/hosting.json`. `params.project_dir` selects another project root. Copy IDs and cursors unchanged.
|
|
6
6
|
|
|
7
|
-
| Topic
|
|
8
|
-
|
|
9
|
-
| `site`
|
|
10
|
-
| `version`
|
|
11
|
-
| `deployment`
|
|
12
|
-
| `access`
|
|
13
|
-
| `environment` | `environment`: `get`, `update`
|
|
14
|
-
| `domains`
|
|
15
|
-
| `analytics`
|
|
16
|
-
| `diagnostics` | `diagnostics`: `logs`
|
|
17
|
-
| `database`
|
|
18
|
-
| `schedules`
|
|
7
|
+
| Topic | Resource actions |
|
|
8
|
+
| ------------- | --------------------------------------------------- |
|
|
9
|
+
| `site` | `site`: `list`, `get`, `create`, `update`, `slug` |
|
|
10
|
+
| `version` | `version`: `list`, `get`, `save`, `publish_private` |
|
|
11
|
+
| `deployment` | `deployment`: `deploy`, `status` |
|
|
12
|
+
| `access` | `access`: `get`, `update` |
|
|
13
|
+
| `environment` | `environment`: `get`, `update` |
|
|
14
|
+
| `domains` | `domain`: `list`, `add`, `refresh`, `remove` |
|
|
15
|
+
| `analytics` | `analytics`: `overview`, `events`, `query` |
|
|
16
|
+
| `diagnostics` | `diagnostics`: `logs` |
|
|
17
|
+
| `database` | `database`: `overview`, `rows` |
|
|
18
|
+
| `schedules` | `schedule`: `create`, `validate` |
|
|
19
19
|
|
|
20
20
|
`building` covers build, storage and connector boundaries. `mcp` covers Site-hosted tools and connection. OAuth, Git credentials, secret environment values and service-access tokens are redacted.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Sites workflow
|
|
2
2
|
|
|
3
3
|
Use only for requested Sites work. Every deployment URL is production. Publish only within the user's requested scope, preserving the current audience. Respect local-only, save-only and no-publication requests.
|
|
4
|
-
|
|
5
4
|
1. Reuse `.openai/hosting.json`'s `project_id`. If absent, `site.create` registers once and merges the ID atomically. Commit that binding with all intended source.
|
|
6
5
|
2. Validate the compatible build locally. Read `building` for runtime constraints.
|
|
7
6
|
3. Use `version.save` for a saved candidate without deployment. For intended publication of new source already known owner-private for this account, use `version.publish_private` instead. Both require a clean, committed, bound repository and push exact HEAD internally.
|
package/dist/src/facade.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import type { SitesClient } from "./client.js";
|
|
2
|
-
export declare function call(request: unknown, client: Pick<SitesClient, "schema" | "call">, cwd: string, signal?: AbortSignal): Promise<
|
|
3
|
-
ok: boolean;
|
|
4
|
-
operation: string;
|
|
5
|
-
result: unknown;
|
|
6
|
-
}>;
|
|
2
|
+
export declare function call(request: unknown, client: Pick<SitesClient, "schema" | "call">, cwd: string, signal?: AbortSignal): Promise<unknown>;
|
|
7
3
|
export declare function documentation(input: string | undefined, client: Pick<SitesClient, "schema">): Promise<string>;
|
package/dist/src/facade.js
CHANGED
|
@@ -20,11 +20,7 @@ export async function call(request, client, cwd, signal) {
|
|
|
20
20
|
validateAgainstSchema(prepared.args, await client.schema(prepared.tool), prepared.allowedExtra);
|
|
21
21
|
const raw = await client.call(prepared.tool, prepared.args);
|
|
22
22
|
const completed = await prepared.after(raw);
|
|
23
|
-
return
|
|
24
|
-
ok: true,
|
|
25
|
-
operation: operation.key,
|
|
26
|
-
result: redact(selectResult(operation, completed)),
|
|
27
|
-
};
|
|
23
|
+
return redact(selectResult(operation, completed));
|
|
28
24
|
}
|
|
29
25
|
finally {
|
|
30
26
|
await prepared.cleanup();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-chatgpt-sites",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "ChatGPT Sites management for Pi, Code Mode and Notebook",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,9 +44,18 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@earendil-works/pi-coding-agent": ">=1.1.0",
|
|
46
46
|
"typebox": "*",
|
|
47
|
-
"@earendil-works/pi-tui": ">=1.0.0"
|
|
47
|
+
"@earendil-works/pi-tui": ">=1.0.0",
|
|
48
|
+
"@howaboua/pi-codex-conversion": ">=4.0.5"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@howaboua/pi-codex-conversion": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@howaboua/pi-codex-conversion": "4.0.5"
|
|
51
60
|
}
|
|
52
61
|
}
|