@agentic-kit/pi 0.17.0 → 0.18.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/README.md +5 -7
- package/confirm-gate.d.ts +1 -2
- package/esm/confirm-gate.d.ts +1 -2
- package/esm/host.d.ts +5 -110
- package/esm/host.js +5 -18
- package/esm/index.d.ts +17 -9
- package/esm/index.js +20 -38
- package/esm/pi-tool.d.ts +16 -0
- package/esm/pi-tool.js +32 -0
- package/host.d.ts +5 -110
- package/host.js +10 -22
- package/index.d.ts +17 -9
- package/index.js +47 -62
- package/package.json +6 -10
- package/pi-tool.d.ts +16 -0
- package/pi-tool.js +36 -0
- package/app-workspace.d.ts +0 -16
- package/app-workspace.js +0 -145
- package/context.d.ts +0 -62
- package/context.js +0 -282
- package/db-probe.d.ts +0 -30
- package/db-probe.js +0 -50
- package/esm/app-workspace.d.ts +0 -16
- package/esm/app-workspace.js +0 -134
- package/esm/context.d.ts +0 -62
- package/esm/context.js +0 -270
- package/esm/db-probe.d.ts +0 -30
- package/esm/db-probe.js +0 -47
- package/esm/policy/add-policies-to-table.d.ts +0 -26
- package/esm/policy/add-policies-to-table.js +0 -66
- package/esm/policy/provision-helpers.d.ts +0 -38
- package/esm/policy/provision-helpers.js +0 -50
- package/esm/provision-database/credential.d.ts +0 -14
- package/esm/provision-database/credential.js +0 -19
- package/esm/provision-database/env-file.d.ts +0 -37
- package/esm/provision-database/env-file.js +0 -85
- package/esm/provision-database/manifest.d.ts +0 -10
- package/esm/provision-database/manifest.js +0 -48
- package/esm/provision-database/pg-fixups.d.ts +0 -16
- package/esm/provision-database/pg-fixups.js +0 -132
- package/esm/provision-database/preset-match.d.ts +0 -13
- package/esm/provision-database/preset-match.js +0 -66
- package/esm/provision-database/presets.d.ts +0 -4
- package/esm/provision-database/presets.js +0 -13
- package/esm/provision-database/request-database.d.ts +0 -61
- package/esm/provision-database/request-database.js +0 -130
- package/esm/provision-database/resolve.d.ts +0 -27
- package/esm/provision-database/resolve.js +0 -49
- package/esm/records/meta.d.ts +0 -41
- package/esm/records/meta.js +0 -167
- package/esm/run-codegen/barrels.d.ts +0 -3
- package/esm/run-codegen/barrels.js +0 -48
- package/esm/run-codegen/endpoints.d.ts +0 -8
- package/esm/run-codegen/endpoints.js +0 -46
- package/esm/schema-resolve.d.ts +0 -23
- package/esm/schema-resolve.js +0 -69
- package/esm/tool-schema.d.ts +0 -3
- package/esm/tool-schema.js +0 -10
- package/esm/tools/add-policies.d.ts +0 -8
- package/esm/tools/add-policies.js +0 -96
- package/esm/tools/add-records.d.ts +0 -14
- package/esm/tools/add-records.js +0 -124
- package/esm/tools/add-relation-schema.d.ts +0 -30
- package/esm/tools/add-relation-schema.js +0 -58
- package/esm/tools/add-relation.d.ts +0 -10
- package/esm/tools/add-relation.js +0 -91
- package/esm/tools/create-api-key.d.ts +0 -18
- package/esm/tools/create-api-key.js +0 -216
- package/esm/tools/describe-schema.d.ts +0 -18
- package/esm/tools/describe-schema.js +0 -132
- package/esm/tools/manage-entity-types.d.ts +0 -41
- package/esm/tools/manage-entity-types.js +0 -203
- package/esm/tools/mutations.d.ts +0 -14
- package/esm/tools/mutations.js +0 -235
- package/esm/tools/provision-blueprint.d.ts +0 -22
- package/esm/tools/provision-blueprint.js +0 -111
- package/esm/tools/provision-database.d.ts +0 -14
- package/esm/tools/provision-database.js +0 -262
- package/esm/tools/run-codegen.d.ts +0 -11
- package/esm/tools/run-codegen.js +0 -139
- package/esm/tools/templates.d.ts +0 -49
- package/esm/tools/templates.js +0 -337
- package/policy/add-policies-to-table.d.ts +0 -26
- package/policy/add-policies-to-table.js +0 -71
- package/policy/provision-helpers.d.ts +0 -38
- package/policy/provision-helpers.js +0 -58
- package/provision-database/credential.d.ts +0 -14
- package/provision-database/credential.js +0 -22
- package/provision-database/env-file.d.ts +0 -37
- package/provision-database/env-file.js +0 -91
- package/provision-database/manifest.d.ts +0 -10
- package/provision-database/manifest.js +0 -56
- package/provision-database/pg-fixups.d.ts +0 -16
- package/provision-database/pg-fixups.js +0 -170
- package/provision-database/preset-match.d.ts +0 -13
- package/provision-database/preset-match.js +0 -70
- package/provision-database/presets.d.ts +0 -4
- package/provision-database/presets.js +0 -17
- package/provision-database/request-database.d.ts +0 -61
- package/provision-database/request-database.js +0 -134
- package/provision-database/resolve.d.ts +0 -27
- package/provision-database/resolve.js +0 -53
- package/records/meta.d.ts +0 -41
- package/records/meta.js +0 -172
- package/run-codegen/barrels.d.ts +0 -3
- package/run-codegen/barrels.js +0 -54
- package/run-codegen/endpoints.d.ts +0 -8
- package/run-codegen/endpoints.js +0 -51
- package/schema-resolve.d.ts +0 -23
- package/schema-resolve.js +0 -75
- package/tool-schema.d.ts +0 -3
- package/tool-schema.js +0 -13
- package/tools/add-policies.d.ts +0 -8
- package/tools/add-policies.js +0 -99
- package/tools/add-records.d.ts +0 -14
- package/tools/add-records.js +0 -127
- package/tools/add-relation-schema.d.ts +0 -30
- package/tools/add-relation-schema.js +0 -62
- package/tools/add-relation.d.ts +0 -10
- package/tools/add-relation.js +0 -94
- package/tools/create-api-key.d.ts +0 -18
- package/tools/create-api-key.js +0 -222
- package/tools/describe-schema.d.ts +0 -18
- package/tools/describe-schema.js +0 -135
- package/tools/manage-entity-types.d.ts +0 -41
- package/tools/manage-entity-types.js +0 -208
- package/tools/mutations.d.ts +0 -14
- package/tools/mutations.js +0 -238
- package/tools/provision-blueprint.d.ts +0 -22
- package/tools/provision-blueprint.js +0 -114
- package/tools/provision-database.d.ts +0 -14
- package/tools/provision-database.js +0 -268
- package/tools/run-codegen.d.ts +0 -11
- package/tools/run-codegen.js +0 -143
- package/tools/templates.d.ts +0 -49
- package/tools/templates.js +0 -341
package/index.js
CHANGED
|
@@ -1,44 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getModulePreset = exports.allModulePresets = exports.toolSchema = exports.resolveProvisionModules = exports.resolveProjectContext = exports.resolveDataToken = exports.PROVISION_MANIFEST_FILE = exports.parseProvisionManifest = exports.moduleKey = exports.loadProvisionManifest = exports.getHost = exports.fromEnvironment = exports.fromEnvFile = exports.deriveSubdomainEndpoint = exports.DEFAULT_PROVISION_PRESET = exports.createTemplatePreviewTables = exports.CONTEXT_ENV_PREFIX = exports.CONTEXT_ENV_KEYS = exports.constructiveDbTools = exports.configureHost = exports.toPiTools = exports.toPiTool = exports.piHarness = exports.PI_HARNESS_ID = exports.createUsageReportExtension = exports.MIRROR_EVENTS = exports.createRunLogExtension = exports.piProviderConfig = exports.createMeteredModelExtension = exports.createGateExtension = exports.startRun = exports.composeRun = exports.createConfirmGate = exports.dbTools = void 0;
|
|
4
4
|
exports.createDbTools = createDbTools;
|
|
5
|
+
const db_tools_1 = require("@agentic-kit/db-tools");
|
|
5
6
|
const confirm_gate_1 = require("./confirm-gate");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const provision_blueprint_1 = require("./tools/provision-blueprint");
|
|
16
|
-
const provision_database_1 = require("./tools/provision-database");
|
|
17
|
-
const run_codegen_1 = require("./tools/run-codegen");
|
|
18
|
-
const templates_1 = require("./tools/templates");
|
|
7
|
+
const pi_tool_1 = require("./pi-tool");
|
|
8
|
+
/**
|
|
9
|
+
* The Constructive db tools bound to pi.
|
|
10
|
+
*
|
|
11
|
+
* The tools themselves live in `@agentic-kit/db-tools` and know nothing about
|
|
12
|
+
* pi; this is the binding — `toPiTool` per tool, plus the confirm gate on pi's
|
|
13
|
+
* `tool_call` event. A sibling adapter writes its own equivalent of this file
|
|
14
|
+
* and registers the same `constructiveDbTools`.
|
|
15
|
+
*/
|
|
19
16
|
const dbTools = (pi) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
pi.registerTool(provision_blueprint_1.provisionBlueprintTool);
|
|
24
|
-
pi.registerTool(add_relation_1.addRelationTool);
|
|
25
|
-
pi.registerTool(mutations_1.deleteTableTool);
|
|
26
|
-
pi.registerTool(mutations_1.createFieldTool);
|
|
27
|
-
pi.registerTool(mutations_1.updateFieldTool);
|
|
28
|
-
pi.registerTool(mutations_1.deleteFieldTool);
|
|
29
|
-
pi.registerTool(add_policies_1.addPoliciesTool);
|
|
30
|
-
pi.registerTool(templates_1.applyTemplateTool);
|
|
31
|
-
pi.registerTool(templates_1.createTemplateTool);
|
|
32
|
-
pi.registerTool(templates_1.updateTemplateTool);
|
|
33
|
-
pi.registerTool(templates_1.deleteTemplateTool);
|
|
34
|
-
pi.registerTool(add_records_1.addRecordsTool);
|
|
35
|
-
pi.registerTool(manage_entity_types_1.manageEntityTypesTool);
|
|
36
|
-
pi.registerTool(create_api_key_1.createApiKeyTool);
|
|
37
|
-
pi.registerTool(run_codegen_1.runCodegenTool);
|
|
17
|
+
for (const tool of db_tools_1.constructiveDbTools) {
|
|
18
|
+
pi.registerTool((0, pi_tool_1.toPiTool)(tool));
|
|
19
|
+
}
|
|
38
20
|
const gate = (0, confirm_gate_1.createConfirmGate)({
|
|
39
|
-
resolveProjectContext:
|
|
40
|
-
resolveDataToken:
|
|
41
|
-
createTemplatePreviewTables:
|
|
21
|
+
resolveProjectContext: db_tools_1.resolveProjectContext,
|
|
22
|
+
resolveDataToken: db_tools_1.resolveDataToken,
|
|
23
|
+
createTemplatePreviewTables: db_tools_1.createTemplatePreviewTables,
|
|
42
24
|
});
|
|
43
25
|
pi.on('agent_start', gate.onAgentStart);
|
|
44
26
|
pi.on('tool_call', gate.onToolCall);
|
|
@@ -46,19 +28,11 @@ const dbTools = (pi) => {
|
|
|
46
28
|
exports.dbTools = dbTools;
|
|
47
29
|
/** Configure the host and get the extension in one call. */
|
|
48
30
|
function createDbTools(host) {
|
|
49
|
-
(0,
|
|
31
|
+
(0, db_tools_1.configureHost)(host);
|
|
50
32
|
return exports.dbTools;
|
|
51
33
|
}
|
|
52
34
|
var confirm_gate_2 = require("./confirm-gate");
|
|
53
35
|
Object.defineProperty(exports, "createConfirmGate", { enumerable: true, get: function () { return confirm_gate_2.createConfirmGate; } });
|
|
54
|
-
var context_2 = require("./context");
|
|
55
|
-
Object.defineProperty(exports, "CONTEXT_ENV_KEYS", { enumerable: true, get: function () { return context_2.CONTEXT_ENV_KEYS; } });
|
|
56
|
-
Object.defineProperty(exports, "CONTEXT_ENV_PREFIX", { enumerable: true, get: function () { return context_2.CONTEXT_ENV_PREFIX; } });
|
|
57
|
-
Object.defineProperty(exports, "deriveSubdomainEndpoint", { enumerable: true, get: function () { return context_2.deriveSubdomainEndpoint; } });
|
|
58
|
-
Object.defineProperty(exports, "fromEnvFile", { enumerable: true, get: function () { return context_2.fromEnvFile; } });
|
|
59
|
-
Object.defineProperty(exports, "fromEnvironment", { enumerable: true, get: function () { return context_2.fromEnvironment; } });
|
|
60
|
-
Object.defineProperty(exports, "resolveDataToken", { enumerable: true, get: function () { return context_2.resolveDataToken; } });
|
|
61
|
-
Object.defineProperty(exports, "resolveProjectContext", { enumerable: true, get: function () { return context_2.resolveProjectContext; } });
|
|
62
36
|
var lanes_1 = require("./embed/lanes");
|
|
63
37
|
Object.defineProperty(exports, "composeRun", { enumerable: true, get: function () { return lanes_1.composeRun; } });
|
|
64
38
|
var session_1 = require("./embed/session");
|
|
@@ -76,22 +50,33 @@ Object.defineProperty(exports, "createUsageReportExtension", { enumerable: true,
|
|
|
76
50
|
var harness_1 = require("./harness");
|
|
77
51
|
Object.defineProperty(exports, "PI_HARNESS_ID", { enumerable: true, get: function () { return harness_1.PI_HARNESS_ID; } });
|
|
78
52
|
Object.defineProperty(exports, "piHarness", { enumerable: true, get: function () { return harness_1.piHarness; } });
|
|
79
|
-
var
|
|
80
|
-
Object.defineProperty(exports, "
|
|
81
|
-
Object.defineProperty(exports, "
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var
|
|
87
|
-
Object.defineProperty(exports, "
|
|
88
|
-
Object.defineProperty(exports, "
|
|
89
|
-
Object.defineProperty(exports, "
|
|
90
|
-
|
|
91
|
-
Object.defineProperty(exports, "
|
|
92
|
-
Object.defineProperty(exports, "
|
|
93
|
-
|
|
94
|
-
Object.defineProperty(exports, "
|
|
95
|
-
|
|
96
|
-
Object.defineProperty(exports, "
|
|
53
|
+
var pi_tool_2 = require("./pi-tool");
|
|
54
|
+
Object.defineProperty(exports, "toPiTool", { enumerable: true, get: function () { return pi_tool_2.toPiTool; } });
|
|
55
|
+
Object.defineProperty(exports, "toPiTools", { enumerable: true, get: function () { return pi_tool_2.toPiTools; } });
|
|
56
|
+
/**
|
|
57
|
+
* The db tools' own surface, re-exported so a pi host keeps one import. The
|
|
58
|
+
* package to depend on directly is `@agentic-kit/db-tools`.
|
|
59
|
+
*/
|
|
60
|
+
var db_tools_2 = require("@agentic-kit/db-tools");
|
|
61
|
+
Object.defineProperty(exports, "configureHost", { enumerable: true, get: function () { return db_tools_2.configureHost; } });
|
|
62
|
+
Object.defineProperty(exports, "constructiveDbTools", { enumerable: true, get: function () { return db_tools_2.constructiveDbTools; } });
|
|
63
|
+
Object.defineProperty(exports, "CONTEXT_ENV_KEYS", { enumerable: true, get: function () { return db_tools_2.CONTEXT_ENV_KEYS; } });
|
|
64
|
+
Object.defineProperty(exports, "CONTEXT_ENV_PREFIX", { enumerable: true, get: function () { return db_tools_2.CONTEXT_ENV_PREFIX; } });
|
|
65
|
+
Object.defineProperty(exports, "createTemplatePreviewTables", { enumerable: true, get: function () { return db_tools_2.createTemplatePreviewTables; } });
|
|
66
|
+
Object.defineProperty(exports, "DEFAULT_PROVISION_PRESET", { enumerable: true, get: function () { return db_tools_2.DEFAULT_PROVISION_PRESET; } });
|
|
67
|
+
Object.defineProperty(exports, "deriveSubdomainEndpoint", { enumerable: true, get: function () { return db_tools_2.deriveSubdomainEndpoint; } });
|
|
68
|
+
Object.defineProperty(exports, "fromEnvFile", { enumerable: true, get: function () { return db_tools_2.fromEnvFile; } });
|
|
69
|
+
Object.defineProperty(exports, "fromEnvironment", { enumerable: true, get: function () { return db_tools_2.fromEnvironment; } });
|
|
70
|
+
Object.defineProperty(exports, "getHost", { enumerable: true, get: function () { return db_tools_2.getHost; } });
|
|
71
|
+
Object.defineProperty(exports, "loadProvisionManifest", { enumerable: true, get: function () { return db_tools_2.loadProvisionManifest; } });
|
|
72
|
+
Object.defineProperty(exports, "moduleKey", { enumerable: true, get: function () { return db_tools_2.moduleKey; } });
|
|
73
|
+
Object.defineProperty(exports, "parseProvisionManifest", { enumerable: true, get: function () { return db_tools_2.parseProvisionManifest; } });
|
|
74
|
+
Object.defineProperty(exports, "PROVISION_MANIFEST_FILE", { enumerable: true, get: function () { return db_tools_2.PROVISION_MANIFEST_FILE; } });
|
|
75
|
+
Object.defineProperty(exports, "resolveDataToken", { enumerable: true, get: function () { return db_tools_2.resolveDataToken; } });
|
|
76
|
+
Object.defineProperty(exports, "resolveProjectContext", { enumerable: true, get: function () { return db_tools_2.resolveProjectContext; } });
|
|
77
|
+
Object.defineProperty(exports, "resolveProvisionModules", { enumerable: true, get: function () { return db_tools_2.resolveProvisionModules; } });
|
|
78
|
+
Object.defineProperty(exports, "toolSchema", { enumerable: true, get: function () { return db_tools_2.toolSchema; } });
|
|
79
|
+
var db_tools_3 = require("@agentic-kit/db-tools");
|
|
80
|
+
Object.defineProperty(exports, "allModulePresets", { enumerable: true, get: function () { return db_tools_3.allModulePresets; } });
|
|
81
|
+
Object.defineProperty(exports, "getModulePreset", { enumerable: true, get: function () { return db_tools_3.getModulePreset; } });
|
|
97
82
|
exports.default = exports.dbTools;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentic-kit/pi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "the pi adapter for agentic-kit — Constructive's typed db tools, confirm gate, and the run-log/metering/gate lanes attached to a pi coding-agent session",
|
|
6
6
|
"main": "index.js",
|
|
@@ -29,21 +29,17 @@
|
|
|
29
29
|
"test:watch": "jest --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"@agentic-kit/harness": "^0.
|
|
32
|
+
"@agentic-kit/db-tools": "^0.2.0",
|
|
33
|
+
"@agentic-kit/harness": "^0.15.0",
|
|
34
34
|
"@agentic-kit/metering": "^0.3.0",
|
|
35
|
-
"@agentic-kit/run-log": "^0.
|
|
36
|
-
"@constructive-io/graphql-query": "^4.14.0",
|
|
37
|
-
"@constructive-io/sdk": "^1.14.0",
|
|
38
|
-
"node-type-registry": "^1.17.0",
|
|
35
|
+
"@agentic-kit/run-log": "^0.6.0",
|
|
39
36
|
"zod": "^4.4.3"
|
|
40
37
|
},
|
|
41
38
|
"peerDependencies": {
|
|
42
39
|
"@earendil-works/pi-coding-agent": ">=0.79.0"
|
|
43
40
|
},
|
|
44
41
|
"devDependencies": {
|
|
45
|
-
"@earendil-works/pi-coding-agent": "0.79.6"
|
|
46
|
-
"typebox": "^1.0.0"
|
|
42
|
+
"@earendil-works/pi-coding-agent": "0.79.6"
|
|
47
43
|
},
|
|
48
44
|
"keywords": [
|
|
49
45
|
"agentic-kit",
|
|
@@ -51,5 +47,5 @@
|
|
|
51
47
|
"coding-agent",
|
|
52
48
|
"constructive"
|
|
53
49
|
],
|
|
54
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "d4bb5506059e1dfb28f2766e6d18e8d946db632d"
|
|
55
51
|
}
|
package/pi-tool.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AnyHarnessTool, HarnessTool } from '@agentic-kit/harness';
|
|
2
|
+
import type { ToolDefinition } from '@earendil-works/pi-coding-agent';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
/**
|
|
5
|
+
* Bind a neutral `HarnessTool` to pi's `ToolDefinition`.
|
|
6
|
+
*
|
|
7
|
+
* This is the whole of what pi wants that a tool does not state: parameters as
|
|
8
|
+
* a typebox schema rather than zod, and an execute arity carrying pi's tool
|
|
9
|
+
* call id, update callback and `ExtensionContext`. Everything a Constructive
|
|
10
|
+
* tool actually reads out of that context is `cwd` and the abort signal, so
|
|
11
|
+
* that is all this forwards — the rest stops here, which is the point of the
|
|
12
|
+
* seam: another harness writes its own binding and the tools do not change.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toPiTool<TParams extends z.ZodType, TDetails>(tool: HarnessTool<TParams, TDetails>): ToolDefinition<any, TDetails>;
|
|
15
|
+
/** Bind a whole tool set, in registration order. */
|
|
16
|
+
export declare function toPiTools(tools: readonly AnyHarnessTool[]): ToolDefinition<any, any>[];
|
package/pi-tool.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toPiTool = toPiTool;
|
|
4
|
+
exports.toPiTools = toPiTools;
|
|
5
|
+
const db_tools_1 = require("@agentic-kit/db-tools");
|
|
6
|
+
/**
|
|
7
|
+
* Bind a neutral `HarnessTool` to pi's `ToolDefinition`.
|
|
8
|
+
*
|
|
9
|
+
* This is the whole of what pi wants that a tool does not state: parameters as
|
|
10
|
+
* a typebox schema rather than zod, and an execute arity carrying pi's tool
|
|
11
|
+
* call id, update callback and `ExtensionContext`. Everything a Constructive
|
|
12
|
+
* tool actually reads out of that context is `cwd` and the abort signal, so
|
|
13
|
+
* that is all this forwards — the rest stops here, which is the point of the
|
|
14
|
+
* seam: another harness writes its own binding and the tools do not change.
|
|
15
|
+
*/
|
|
16
|
+
function toPiTool(tool) {
|
|
17
|
+
return {
|
|
18
|
+
name: tool.name,
|
|
19
|
+
label: tool.label,
|
|
20
|
+
description: tool.description,
|
|
21
|
+
...(tool.promptSnippet === undefined ? {} : { promptSnippet: tool.promptSnippet }),
|
|
22
|
+
...(tool.promptGuidelines === undefined ? {} : { promptGuidelines: tool.promptGuidelines }),
|
|
23
|
+
parameters: (0, db_tools_1.toolSchema)(tool.parameters),
|
|
24
|
+
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
25
|
+
const result = await tool.execute(params, {
|
|
26
|
+
cwd: ctx.cwd,
|
|
27
|
+
signal,
|
|
28
|
+
});
|
|
29
|
+
return result;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Bind a whole tool set, in registration order. */
|
|
34
|
+
function toPiTools(tools) {
|
|
35
|
+
return tools.map((tool) => toPiTool(tool));
|
|
36
|
+
}
|
package/app-workspace.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const NATIVE_BUILD_DEPS: string[];
|
|
2
|
-
export declare const IGNORED_BUILDS_RE: RegExp;
|
|
3
|
-
export declare function run(cmd: string, args: string[], cwd: string, env?: Record<string, string>): Promise<{
|
|
4
|
-
ok: boolean;
|
|
5
|
-
out: string;
|
|
6
|
-
}>;
|
|
7
|
-
export declare function ensureWorkspaceConfig(cwd: string): Promise<void>;
|
|
8
|
-
export declare function pinCodegenLatest(appDir: string): Promise<void>;
|
|
9
|
-
export declare function ensureAppScaffold(cwd: string): Promise<{
|
|
10
|
-
ok: boolean;
|
|
11
|
-
out: string;
|
|
12
|
-
}>;
|
|
13
|
-
export declare function prewarmAppWorkspace(cwd: string): Promise<{
|
|
14
|
-
ok: boolean;
|
|
15
|
-
out: string;
|
|
16
|
-
}>;
|
package/app-workspace.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.IGNORED_BUILDS_RE = exports.NATIVE_BUILD_DEPS = void 0;
|
|
7
|
-
exports.run = run;
|
|
8
|
-
exports.ensureWorkspaceConfig = ensureWorkspaceConfig;
|
|
9
|
-
exports.pinCodegenLatest = pinCodegenLatest;
|
|
10
|
-
exports.ensureAppScaffold = ensureAppScaffold;
|
|
11
|
-
exports.prewarmAppWorkspace = prewarmAppWorkspace;
|
|
12
|
-
const node_child_process_1 = require("node:child_process");
|
|
13
|
-
const node_fs_1 = require("node:fs");
|
|
14
|
-
const promises_1 = require("node:fs/promises");
|
|
15
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
16
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
-
const node_util_1 = require("node:util");
|
|
18
|
-
const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
19
|
-
// pnpm 11.8 no longer reads the `pnpm` field from a non-root package.json, so the
|
|
20
|
-
// template's `pnpm.overrides.graphql` (in packages/app/package.json) is silently
|
|
21
|
-
// ignored. Without that override two graphql versions (16.13.0 + 16.14.0) get
|
|
22
|
-
// installed, which instantiates two copies of `grafast` under DIFFERENT
|
|
23
|
-
// peer-dependency hash contexts. graphile-search then resolves in one context
|
|
24
|
-
// while graphile-connection-filter was linked under the other, so codegen dies
|
|
25
|
-
// with `Cannot find module 'graphile-connection-filter'`. Hoisting the override
|
|
26
|
-
// to the ROOT pnpm-workspace.yaml (which pnpm 11.8 DOES read) collapses graphql —
|
|
27
|
-
// and therefore grafast — to a single version, and the missing module resolves
|
|
28
|
-
// (PNPM-GRAPHQL-OVERRIDE-001). We also strip the nested packages/app
|
|
29
|
-
// pnpm-workspace.yaml the template ships, and keep onlyBuiltDependencies so the
|
|
30
|
-
// native deps build where honored (PNPM-BUILDS-001).
|
|
31
|
-
exports.NATIVE_BUILD_DEPS = ['esbuild', 'sharp', 'unrs-resolver'];
|
|
32
|
-
exports.IGNORED_BUILDS_RE = /ERR_PNPM_IGNORED_BUILDS|Ignored build scripts/;
|
|
33
|
-
const DEFAULT_GRAPHQL_OVERRIDE = '16.14.0';
|
|
34
|
-
const TEMPLATE_REPO = 'https://github.com/constructive-io/sandbox-templates';
|
|
35
|
-
const TEMPLATE_SUBDIR = node_path_1.default.join('nextjs', 'constructive-app');
|
|
36
|
-
async function run(cmd, args, cwd, env) {
|
|
37
|
-
try {
|
|
38
|
-
const { stdout, stderr } = await execFileAsync(cmd, args, {
|
|
39
|
-
cwd,
|
|
40
|
-
timeout: 5 * 60_000,
|
|
41
|
-
encoding: 'utf-8',
|
|
42
|
-
maxBuffer: 32 * 1024 * 1024,
|
|
43
|
-
env: env ? { ...process.env, ...env } : process.env,
|
|
44
|
-
});
|
|
45
|
-
return { ok: true, out: `${stdout}${stderr}`.trim() };
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
const e = err;
|
|
49
|
-
return { ok: false, out: `${e.stdout ?? ''}${e.stderr ?? ''}`.trim() || e.message || 'failed' };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Read the graphql pin the template wants from its (now-ignored) pnpm.overrides
|
|
53
|
-
// so we propagate the template's own value instead of hardcoding ours.
|
|
54
|
-
async function templateGraphqlOverride(cwd) {
|
|
55
|
-
try {
|
|
56
|
-
const pkg = JSON.parse(await (0, promises_1.readFile)(node_path_1.default.join(cwd, 'packages', 'app', 'package.json'), 'utf8'));
|
|
57
|
-
const v = pkg?.pnpm?.overrides?.graphql;
|
|
58
|
-
return typeof v === 'string' && v.length > 0 ? v : DEFAULT_GRAPHQL_OVERRIDE;
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return DEFAULT_GRAPHQL_OVERRIDE;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async function ensureWorkspaceConfig(cwd) {
|
|
65
|
-
const nested = node_path_1.default.join(cwd, 'packages', 'app', 'pnpm-workspace.yaml');
|
|
66
|
-
if ((0, node_fs_1.existsSync)(nested)) {
|
|
67
|
-
await (0, promises_1.rm)(nested, { force: true });
|
|
68
|
-
}
|
|
69
|
-
const graphqlPin = await templateGraphqlOverride(cwd);
|
|
70
|
-
const builds = exports.NATIVE_BUILD_DEPS.map((d) => ` - ${d}`).join('\n');
|
|
71
|
-
const text = `packages:\n - "packages/*"\n\n` +
|
|
72
|
-
`overrides:\n graphql: ${graphqlPin}\n\n` +
|
|
73
|
-
`onlyBuiltDependencies:\n${builds}\n`;
|
|
74
|
-
await (0, promises_1.writeFile)(node_path_1.default.join(cwd, 'pnpm-workspace.yaml'), text);
|
|
75
|
-
}
|
|
76
|
-
// Force @constructive-io/graphql-codegen to `latest` in the app package.json
|
|
77
|
-
// before the single install — older 4.9.x throws on PostGraphile `filter` inputs
|
|
78
|
-
// (TS-001).
|
|
79
|
-
async function pinCodegenLatest(appDir) {
|
|
80
|
-
const pkgPath = node_path_1.default.join(appDir, 'package.json');
|
|
81
|
-
const pkg = JSON.parse(await (0, promises_1.readFile)(pkgPath, 'utf8'));
|
|
82
|
-
for (const field of ['devDependencies', 'dependencies']) {
|
|
83
|
-
if (pkg[field]?.['@constructive-io/graphql-codegen']) {
|
|
84
|
-
pkg[field]['@constructive-io/graphql-codegen'] = 'latest';
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
await (0, promises_1.writeFile)(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
88
|
-
}
|
|
89
|
-
// The Constructive Next.js app is just the `nextjs/constructive-app` tree from
|
|
90
|
-
// the sandbox-templates repo — it ships no `____VAR____` placeholders, so there
|
|
91
|
-
// is nothing to templatize. `pgpm init` only fetches and copies that tree, but
|
|
92
|
-
// its CLI is unreliable in the non-TTY agent shell, which made the agent thrash
|
|
93
|
-
// for minutes. Materialize `packages/app` deterministically by shallow-cloning
|
|
94
|
-
// the template instead (PGPM-001).
|
|
95
|
-
async function ensureAppScaffold(cwd) {
|
|
96
|
-
const appDir = node_path_1.default.join(cwd, 'packages', 'app');
|
|
97
|
-
if ((0, node_fs_1.existsSync)(node_path_1.default.join(appDir, 'package.json'))) {
|
|
98
|
-
return { ok: true, out: 'packages/app already scaffolded' };
|
|
99
|
-
}
|
|
100
|
-
const tmp = node_path_1.default.join(node_os_1.default.tmpdir(), `airpage-app-template-${process.pid}`);
|
|
101
|
-
await (0, promises_1.rm)(tmp, { recursive: true, force: true });
|
|
102
|
-
const clone = await run('git', ['clone', '--depth', '1', TEMPLATE_REPO, tmp], cwd);
|
|
103
|
-
if (!clone.ok) {
|
|
104
|
-
await (0, promises_1.rm)(tmp, { recursive: true, force: true });
|
|
105
|
-
return { ok: false, out: `Template clone failed:\n${clone.out}` };
|
|
106
|
-
}
|
|
107
|
-
const src = node_path_1.default.join(tmp, TEMPLATE_SUBDIR);
|
|
108
|
-
if (!(0, node_fs_1.existsSync)(src)) {
|
|
109
|
-
await (0, promises_1.rm)(tmp, { recursive: true, force: true });
|
|
110
|
-
return { ok: false, out: `Template subdir ${TEMPLATE_SUBDIR} missing in ${TEMPLATE_REPO}` };
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
await (0, promises_1.mkdir)(node_path_1.default.dirname(appDir), { recursive: true });
|
|
114
|
-
await (0, promises_1.cp)(src, appDir, { recursive: true });
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
await (0, promises_1.rm)(tmp, { recursive: true, force: true });
|
|
118
|
-
return {
|
|
119
|
-
ok: false,
|
|
120
|
-
out: `Copying template into packages/app failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
await (0, promises_1.rm)(tmp, { recursive: true, force: true });
|
|
124
|
-
return { ok: true, out: 'Scaffolded packages/app from the constructive-app template.' };
|
|
125
|
-
}
|
|
126
|
-
// Scaffold packages/app, hoist the workspace config, pin codegen, and run the one
|
|
127
|
-
// clean install. All of this is database-INDEPENDENT, so it can be prewarmed
|
|
128
|
-
// concurrently with the ~90s provision_database backend mutation to keep clone +
|
|
129
|
-
// install off run_codegen's critical path. Best-effort and fully idempotent:
|
|
130
|
-
// run_codegen re-runs the same steps, finding the scaffold present and the install
|
|
131
|
-
// already satisfied (a fast no-op). Errors are swallowed by callers that prewarm —
|
|
132
|
-
// run_codegen surfaces any real failure later.
|
|
133
|
-
async function prewarmAppWorkspace(cwd) {
|
|
134
|
-
const scaffold = await ensureAppScaffold(cwd);
|
|
135
|
-
if (!scaffold.ok)
|
|
136
|
-
return scaffold;
|
|
137
|
-
const appDir = node_path_1.default.join(cwd, 'packages', 'app');
|
|
138
|
-
await ensureWorkspaceConfig(cwd);
|
|
139
|
-
await pinCodegenLatest(appDir);
|
|
140
|
-
const install = await run('pnpm', ['install', '--no-frozen-lockfile'], cwd);
|
|
141
|
-
if (!install.ok && !exports.IGNORED_BUILDS_RE.test(install.out)) {
|
|
142
|
-
return { ok: false, out: `pnpm install failed:\n${install.out}` };
|
|
143
|
-
}
|
|
144
|
-
return { ok: true, out: 'Prewarmed packages/app scaffold + install.' };
|
|
145
|
-
}
|
package/context.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { api, modules } from '@constructive-io/sdk';
|
|
2
|
-
export type ApiClient = ReturnType<typeof api.createClient>;
|
|
3
|
-
export type ModulesClient = ReturnType<typeof modules.createClient>;
|
|
4
|
-
export type ProjectContext = {
|
|
5
|
-
api: ApiClient;
|
|
6
|
-
modules: ModulesClient;
|
|
7
|
-
databaseId: string;
|
|
8
|
-
schemaId: string;
|
|
9
|
-
ownerId: string | undefined;
|
|
10
|
-
apiEndpoint: string;
|
|
11
|
-
modulesEndpoint: string;
|
|
12
|
-
databaseName: string;
|
|
13
|
-
accessToken: string;
|
|
14
|
-
dataEndpoint: string;
|
|
15
|
-
};
|
|
16
|
-
export type ProjectContextFailureCode = 'no-env' | 'missing-credentials' | 'db-missing' | 'account-mismatch' | 'backend-unreachable' | 'schema-unresolved';
|
|
17
|
-
export type ResolveResult = {
|
|
18
|
-
context: ProjectContext | null;
|
|
19
|
-
reason: string;
|
|
20
|
-
code?: ProjectContextFailureCode;
|
|
21
|
-
};
|
|
22
|
-
export declare const CONTEXT_ENV_KEYS: readonly ["ACCESS_TOKEN", "DATABASE_ID", "API_ENDPOINT", "MODULES_ENDPOINT", "DATABASE_NAME", "OWNER_ID"];
|
|
23
|
-
export type ContextEnvKey = (typeof CONTEXT_ENV_KEYS)[number];
|
|
24
|
-
/** Prefix for injected variables: `ACCESS_TOKEN` is far too generic to claim in
|
|
25
|
-
* a shared process environment, `CONSTRUCTIVE_ACCESS_TOKEN` is not. Inside a
|
|
26
|
-
* project `.env` the bare names stay readable (and are what the scaffolder
|
|
27
|
-
* writes), so both spellings resolve, prefixed winning. */
|
|
28
|
-
export declare const CONTEXT_ENV_PREFIX = "CONSTRUCTIVE_";
|
|
29
|
-
/** Values keyed by name, or a lookup function (a host with a secret store). */
|
|
30
|
-
export type ContextSource = Record<string, string | undefined> | ((name: string) => string | undefined);
|
|
31
|
-
/** Use the process environment (or any injected record) as the source. */
|
|
32
|
-
export declare function fromEnvironment(environment?: Record<string, string | undefined>): ContextSource;
|
|
33
|
-
/** Read a project `.env` as the source. The file is authoritative here — the
|
|
34
|
-
* key in it belongs to whatever backend wrote it, so it is not merged under
|
|
35
|
-
* the ambient environment. Returns null when the file is absent. */
|
|
36
|
-
export declare function fromEnvFile(cwd: string): Promise<ContextSource | null>;
|
|
37
|
-
export type ResolveOptions = {
|
|
38
|
-
/** Which plane the context is for. Ownership gates the control plane only:
|
|
39
|
-
* schema editing and provisioning act under the signed-in account, so a
|
|
40
|
-
* foreign-owned binding is blocked ('account-mismatch'). The data plane
|
|
41
|
-
* (real rows via app end-user tokens) never checks desktop-account
|
|
42
|
-
* ownership — a live foreign-owned database serves data fine, exactly as
|
|
43
|
-
* the app itself does in the Preview. */
|
|
44
|
-
plane?: 'control' | 'data';
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Resolve the project context from injected values, or from a project folder.
|
|
48
|
-
*
|
|
49
|
-
* Passing a `cwd` string keeps the original behavior (read `<cwd>/.env`) so
|
|
50
|
-
* existing hosts — Constructive Desktop, the confirm gate — are unchanged.
|
|
51
|
-
* Headless hosts pass values instead: `fromEnvironment()` for a container or
|
|
52
|
-
* Job, an explicit record for anything else.
|
|
53
|
-
*/
|
|
54
|
-
export declare function resolveProjectContext(input: string | ContextSource, options?: ResolveOptions): Promise<ResolveResult>;
|
|
55
|
-
export type DataTokenResult = {
|
|
56
|
-
token?: string;
|
|
57
|
-
userId?: string;
|
|
58
|
-
reason?: string;
|
|
59
|
-
};
|
|
60
|
-
export declare function resolveDataToken(context: ProjectContext): Promise<DataTokenResult>;
|
|
61
|
-
export declare function deriveSubdomainEndpoint(baseEndpoint: string, firstLabel: string): string;
|
|
62
|
-
export declare function resolveOrgName(ownerId: string): Promise<string | undefined>;
|