nolo-cli 0.1.32 → 0.1.33
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 +0 -6
- package/agent-runtime/agentRecordConfig.ts +2 -0
- package/agent-runtime/hostAdapter.ts +1 -0
- package/agent-runtime/index.ts +0 -21
- package/agent-runtime/localToolPolicy.ts +6 -13
- package/agent-runtime/localWorkspaceTools.ts +30 -333
- package/agent-runtime/platformChatProvider.ts +1 -4
- package/agent-runtime/runtimeToolPolicy.ts +47 -32
- package/agentAliases.ts +14 -83
- package/agentCommandSupport.ts +3 -6
- package/agentInternalCommandEntries.ts +2 -13
- package/agentListCommands.ts +19 -28
- package/agentMachineCommands.ts +40 -336
- package/agentPullCommand.ts +36 -56
- package/agentRecordCommands.ts +3 -5
- package/agentRecordHelpers.ts +22 -189
- package/agentRunCommand.ts +438 -107
- package/agentRuntimeLocal.ts +0 -10
- package/ai/agent/cliExecutor.ts +19 -323
- package/authCommands.ts +2 -36
- package/cli/agentAliases.ts +14 -83
- package/cli/agentCommandSupport.ts +3 -6
- package/cli/agentInternalCommandEntries.ts +2 -13
- package/cli/agentListCommands.ts +19 -28
- package/cli/agentMachineCommands.ts +40 -336
- package/cli/agentPullCommand.ts +36 -56
- package/cli/agentRecordCommands.ts +3 -5
- package/cli/agentRecordHelpers.ts +22 -189
- package/cli/agentRunCommand.ts +438 -107
- package/cli/agentRuntimeLocal.ts +0 -10
- package/cli/authCommands.ts +2 -36
- package/cli/cliEnvHelpers.ts +21 -162
- package/cli/client/agentRun.ts +853 -57
- package/cli/client/localRuntimeAdapter.ts +22 -159
- package/cli/client/streamingOutput.ts +3 -1
- package/cli/client/taskRunPrompt.ts +24 -7
- package/cli/commandRegistry.ts +2 -3
- package/cli/connectorRunArtifact.ts +10 -34
- package/cli/connectorWebSocketTarget.ts +6 -10
- package/cli/internalCommandEntries.ts +0 -8
- package/cli/localRuntimeDb.ts +2 -39
- package/cli/machineCommands.ts +189 -190
- package/cli/machineDaemonCommands.ts +165 -9
- package/cli/machineHeartbeatCommands.ts +2 -1
- package/cli/machineStatusCommands.ts +13 -5
- package/cli/machineWatchCommands.ts +1 -1
- package/cli/machineWsRunDispatch.ts +14 -48
- package/cli/machineWsSession.ts +0 -2
- package/cli/offlineMarxistsAgentCommand.ts +314 -0
- package/cli/runtimeDoctorCommands.ts +69 -18
- package/cli/scriptCommandEntries.ts +45 -5
- package/cli/tableCommands.ts +133 -33
- package/cli/taskRunCommand.ts +211 -16
- package/cli/tui/session.ts +372 -43
- package/cli/workflowInternalCommandEntries.ts +0 -20
- package/cliEnvHelpers.ts +21 -162
- package/client/agentConfigResolver.test.ts +2 -0
- package/client/agentRun.test.ts +12 -208
- package/client/agentRun.ts +853 -57
- package/client/localRuntimeAdapter.test.ts +9 -168
- package/client/localRuntimeAdapter.ts +22 -159
- package/client/localToolPolicy.test.ts +4 -28
- package/client/streamingOutput.ts +3 -1
- package/client/taskRunPrompt.ts +24 -7
- package/commandRegistry.ts +2 -3
- package/connectorRunArtifact.ts +10 -34
- package/connectorWebSocketTarget.ts +6 -10
- package/database/server/db.ts +34 -15
- package/internalCommandEntries.ts +0 -8
- package/localRuntimeDb.ts +2 -39
- package/machineCommands.ts +189 -190
- package/machineDaemonCommands.ts +165 -9
- package/machineHeartbeatCommands.ts +2 -1
- package/machineStatusCommands.ts +13 -5
- package/machineWatchCommands.ts +1 -1
- package/machineWsRunDispatch.ts +14 -48
- package/machineWsSession.ts +0 -2
- package/offlineMarxistsAgentCommand.ts +314 -0
- package/package.json +49 -193
- package/runtimeDoctorCommands.ts +69 -18
- package/scriptCommandEntries.ts +45 -5
- package/tableCommands.ts +133 -33
- package/taskRunCommand.ts +211 -16
- package/tui/session.ts +372 -43
- package/workflowInternalCommandEntries.ts +0 -20
- package/agent-runtime/dialogStatus.ts +0 -139
- package/agent-runtime/hostRuntimeConfig.ts +0 -86
- package/agentCreateCustomCommands.ts +0 -278
- package/agentDialogsCommands.ts +0 -227
- package/agentDoctorCommands.ts +0 -203
- package/agentRunLocalWorkspace.ts +0 -182
- package/agentRunParsing.ts +0 -298
- package/agentSuperviseCommands.ts +0 -8
- package/agentUnpublishCommands.ts +0 -113
- package/ai/agent/agentRunDialogLineage.ts +0 -56
- package/ai/policy/types.ts +0 -64
- package/ai/skills/skillSummaryMarker.ts +0 -26
- package/app/types.ts +0 -358
- package/build.ts +0 -16
- package/buildPublish.ts +0 -138
- package/buildPublishArtifactAssembly.ts +0 -724
- package/buildPublishImportAnalysis.ts +0 -242
- package/chat/messages/fetchMessages.ts +0 -84
- package/chat/messages/types.ts +0 -185
- package/cli/agentCreateCustomCommands.ts +0 -278
- package/cli/agentDialogsCommands.ts +0 -227
- package/cli/agentDoctorCommands.ts +0 -203
- package/cli/agentRunLocalWorkspace.ts +0 -182
- package/cli/agentRunParsing.ts +0 -298
- package/cli/agentSuperviseCommands.ts +0 -8
- package/cli/agentUnpublishCommands.ts +0 -113
- package/cli/buildPublish.ts +0 -138
- package/cli/buildPublishArtifactAssembly.ts +0 -724
- package/cli/buildPublishImportAnalysis.ts +0 -242
- package/cli/cliIoTypes.ts +0 -3
- package/cli/cliRuntimeDoctorReport.ts +0 -193
- package/cli/client/agentRunInput.ts +0 -10
- package/cli/client/agentRunLocalExecution.ts +0 -124
- package/cli/client/agentRunLocalExecutor.ts +0 -179
- package/cli/client/agentRunRuntimeSelection.ts +0 -145
- package/cli/client/agentRunServerTransport.ts +0 -397
- package/cli/client/agentRunTaskRunRecorder.ts +0 -176
- package/cli/customCodingAgentFlow.ts +0 -208
- package/cli/customCodingAgentRecord.ts +0 -179
- package/cli/dialogDataAccess.ts +0 -186
- package/cli/dialogInternalCommandEntries.ts +0 -11
- package/cli/dialogReadCommands.ts +0 -180
- package/cli/dialogReadHelpers.ts +0 -226
- package/cli/dialogStatusCommands.ts +0 -123
- package/cli/docInternalCommandEntries.ts +0 -20
- package/cli/hybridReadHelpers.ts +0 -109
- package/cli/machineCommandPrompts.ts +0 -79
- package/cli/machineCommandResolution.ts +0 -43
- package/cli/noloReadBridgePrompt.ts +0 -16
- package/cli/pageCreateCommands.ts +0 -219
- package/cli/pageDeleteCommands.ts +0 -167
- package/cli/pageReadCommands.ts +0 -151
- package/cli/pageUpdateCommands.ts +0 -249
- package/cli/pageWriteHelpers.ts +0 -209
- package/cli/publishPackage.ts +0 -36
- package/cli/runtimeInternalCommandEntries.ts +0 -15
- package/cli/runtimePassthroughCommands.ts +0 -22
- package/cli/scriptPassthroughHelpers.ts +0 -28
- package/cli/secretScanHelpers.ts +0 -31
- package/cli/spaceAttachCommands.ts +0 -134
- package/cli/spaceCategoryCommands.ts +0 -263
- package/cli/spaceCommands.ts +0 -295
- package/cli/spaceDeleteCommands.ts +0 -312
- package/cli/spaceInternalCommandEntries.ts +0 -21
- package/cli/spaceMutationHelpers.ts +0 -135
- package/cli/spaceReadCommands.ts +0 -323
- package/cli/tableDataOutput.ts +0 -41
- package/cli/tableDataSafety.ts +0 -26
- package/cli/tableMetaCommands.ts +0 -307
- package/cli/tableMutationCommands.ts +0 -266
- package/cli/tableQueryParsing.ts +0 -90
- package/cli/tableQueryRequest.ts +0 -53
- package/cli/taskRunActions.ts +0 -122
- package/cli/taskRunParsing.ts +0 -86
- package/cli/taskRunPromptShared.ts +0 -55
- package/cli/tui/tuiCatalog.ts +0 -22
- package/cli/tui/tuiCommandInterpreter.ts +0 -253
- package/cli/tui/tuiPresentation.ts +0 -146
- package/cliIoTypes.ts +0 -3
- package/cliRuntimeDoctorReport.ts +0 -193
- package/client/agentRunInput.ts +0 -10
- package/client/agentRunLocalExecution.test.ts +0 -123
- package/client/agentRunLocalExecution.ts +0 -124
- package/client/agentRunLocalExecutor.ts +0 -179
- package/client/agentRunRuntimeSelection.test.ts +0 -159
- package/client/agentRunRuntimeSelection.ts +0 -145
- package/client/agentRunServerTransport.ts +0 -397
- package/client/agentRunTaskRunRecorder.ts +0 -176
- package/connector-experimental/daemonLauncher.ts +0 -223
- package/create/space/spaceKeys.ts +0 -65
- package/create/types.ts +0 -21
- package/customCodingAgentFlow.ts +0 -208
- package/customCodingAgentRecord.ts +0 -179
- package/database/keys.ts +0 -765
- package/database/server/authorityStoreTypes.ts +0 -31
- package/database/server/legacyServerDb.ts +0 -58
- package/database/server/levelAuthorityStore.ts +0 -75
- package/database/server/memoryAuthorityStore.ts +0 -133
- package/database/server/serverStoreFactory.ts +0 -124
- package/database/tombstones.ts +0 -52
- package/database/utils/ulid.ts +0 -1
- package/dialogDataAccess.ts +0 -186
- package/dialogInternalCommandEntries.ts +0 -11
- package/dialogReadCommands.ts +0 -180
- package/dialogReadHelpers.ts +0 -226
- package/dialogStatusCommands.ts +0 -123
- package/docInternalCommandEntries.ts +0 -20
- package/hybridReadHelpers.ts +0 -109
- package/machineCommandPrompts.ts +0 -79
- package/machineCommandResolution.ts +0 -43
- package/noloReadBridgePrompt.ts +0 -16
- package/pageCreateCommands.ts +0 -219
- package/pageDeleteCommands.ts +0 -167
- package/pageReadCommands.ts +0 -151
- package/pageUpdateCommands.ts +0 -249
- package/pageWriteHelpers.ts +0 -209
- package/publishPackage.ts +0 -36
- package/runtimeInternalCommandEntries.ts +0 -15
- package/runtimePassthroughCommands.ts +0 -22
- package/scriptPassthroughHelpers.ts +0 -28
- package/secretScanHelpers.ts +0 -31
- package/share/helpers.ts +0 -302
- package/share/keys.ts +0 -243
- package/share/types.ts +0 -100
- package/spaceAttachCommands.ts +0 -134
- package/spaceCategoryCommands.ts +0 -263
- package/spaceCommands.ts +0 -295
- package/spaceDeleteCommands.ts +0 -312
- package/spaceInternalCommandEntries.ts +0 -21
- package/spaceMutationHelpers.ts +0 -135
- package/spaceReadCommands.ts +0 -323
- package/tableDataOutput.ts +0 -41
- package/tableDataSafety.ts +0 -26
- package/tableMetaCommands.ts +0 -307
- package/tableMutationCommands.ts +0 -266
- package/tableQueryParsing.ts +0 -90
- package/tableQueryRequest.ts +0 -53
- package/taskRunActions.ts +0 -122
- package/taskRunParsing.ts +0 -86
- package/taskRunPromptShared.ts +0 -55
- package/tui/tuiCatalog.ts +0 -22
- package/tui/tuiCommandInterpreter.test.ts +0 -169
- package/tui/tuiCommandInterpreter.ts +0 -253
- package/tui/tuiPresentation.test.ts +0 -154
- package/tui/tuiPresentation.ts +0 -146
package/tableMutationCommands.ts
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import type { OutputLike } from "./cliIoTypes";
|
|
2
|
-
import {
|
|
3
|
-
formatOutput,
|
|
4
|
-
hasFlag,
|
|
5
|
-
parseJsonOption,
|
|
6
|
-
parseJwtTenantId,
|
|
7
|
-
parseOutputMode,
|
|
8
|
-
parseTableArg,
|
|
9
|
-
readOption,
|
|
10
|
-
resolveAuthToken,
|
|
11
|
-
resolveServerUrl,
|
|
12
|
-
type EnvLike,
|
|
13
|
-
} from "./tableQueryParsing";
|
|
14
|
-
import { assertTableSchemaWriteAllowed } from "./tableDataSafety";
|
|
15
|
-
|
|
16
|
-
type TableMutationDeps = {
|
|
17
|
-
env?: EnvLike;
|
|
18
|
-
output?: OutputLike;
|
|
19
|
-
fetchImpl?: typeof fetch;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function usage() {
|
|
23
|
-
return [
|
|
24
|
-
"Usage:",
|
|
25
|
-
" nolo table data --table <tableId|metaKey> [--tenant-id <userId>] [--action <add-column|add-row|add-rows|update-row|update-rows|delete-row|delete-rows>] [payload flags]",
|
|
26
|
-
"",
|
|
27
|
-
].join("\n");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function resolveRowTarget(raw?: string) {
|
|
31
|
-
if (!raw?.trim()) return {};
|
|
32
|
-
const trimmed = raw.trim();
|
|
33
|
-
if (trimmed.startsWith("row-")) {
|
|
34
|
-
return { dbKey: trimmed };
|
|
35
|
-
}
|
|
36
|
-
return { rowId: trimmed };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function readTableMeta(args: {
|
|
40
|
-
authToken: string;
|
|
41
|
-
dbKey: string;
|
|
42
|
-
fetchImpl: typeof fetch;
|
|
43
|
-
serverUrl: string;
|
|
44
|
-
}) {
|
|
45
|
-
const response = await args.fetchImpl(`${args.serverUrl}/api/v1/db/read/${encodeURIComponent(args.dbKey)}`, {
|
|
46
|
-
method: "GET",
|
|
47
|
-
headers: {
|
|
48
|
-
Authorization: `Bearer ${args.authToken}`,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
const data = await response.json().catch(() => ({}));
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
throw new Error(`failed to read table meta (${response.status}): ${JSON.stringify(data)}`);
|
|
54
|
-
}
|
|
55
|
-
return data?.data ?? data;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async function postTableAction(args: {
|
|
59
|
-
authToken: string;
|
|
60
|
-
body: Record<string, unknown>;
|
|
61
|
-
fetchImpl: typeof fetch;
|
|
62
|
-
path: string;
|
|
63
|
-
serverUrl: string;
|
|
64
|
-
}) {
|
|
65
|
-
const response = await args.fetchImpl(`${args.serverUrl}${args.path}`, {
|
|
66
|
-
method: "POST",
|
|
67
|
-
headers: {
|
|
68
|
-
Authorization: `Bearer ${args.authToken}`,
|
|
69
|
-
"Content-Type": "application/json",
|
|
70
|
-
},
|
|
71
|
-
body: JSON.stringify(args.body),
|
|
72
|
-
});
|
|
73
|
-
const data = await response.json().catch(() => ({}));
|
|
74
|
-
if (!response.ok) {
|
|
75
|
-
throw new Error(`${args.path} failed (${response.status}): ${JSON.stringify(data)}`);
|
|
76
|
-
}
|
|
77
|
-
return data?.rawData ?? data;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function buildMutationRequest(args: {
|
|
81
|
-
action: string;
|
|
82
|
-
rawArgs: string[];
|
|
83
|
-
tableId: string;
|
|
84
|
-
tenantId: string;
|
|
85
|
-
}) {
|
|
86
|
-
const { action, rawArgs, tableId, tenantId } = args;
|
|
87
|
-
switch (action) {
|
|
88
|
-
case "add-column": {
|
|
89
|
-
const name = readOption(rawArgs, "--name")?.trim();
|
|
90
|
-
if (!name) throw new Error("--name is required.");
|
|
91
|
-
const options = parseJsonOption<string[]>(rawArgs, "--options");
|
|
92
|
-
return {
|
|
93
|
-
path: "/api/table/add-column",
|
|
94
|
-
body: {
|
|
95
|
-
tenantId,
|
|
96
|
-
tableId,
|
|
97
|
-
name,
|
|
98
|
-
...(readOption(rawArgs, "--label") ? { label: readOption(rawArgs, "--label") } : {}),
|
|
99
|
-
...(readOption(rawArgs, "--type") ? { type: readOption(rawArgs, "--type") } : {}),
|
|
100
|
-
...(options ? { options } : {}),
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
case "add-row": {
|
|
105
|
-
const values = parseJsonOption<Record<string, unknown>>(rawArgs, "--values");
|
|
106
|
-
if (!values || Array.isArray(values)) {
|
|
107
|
-
throw new Error("--values must be a JSON object.");
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
path: "/api/table/add-row",
|
|
111
|
-
body: { tenantId, tableId, values },
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
case "add-rows": {
|
|
115
|
-
const rows = parseJsonOption<Array<Record<string, unknown>>>(rawArgs, "--rows");
|
|
116
|
-
if (!Array.isArray(rows) || rows.length === 0) {
|
|
117
|
-
throw new Error("--rows must be a non-empty JSON array.");
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
path: "/api/table/add-rows",
|
|
121
|
-
body: { tenantId, tableId, rows },
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
case "update-row": {
|
|
125
|
-
const target = resolveRowTarget(readOption(rawArgs, "--row"));
|
|
126
|
-
const changes = parseJsonOption<Record<string, unknown>>(rawArgs, "--changes");
|
|
127
|
-
if ((!target.rowId && !target.dbKey) || !changes || Array.isArray(changes)) {
|
|
128
|
-
throw new Error("--row and --changes are required, and --changes must be an object.");
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
path: "/api/table/update-row",
|
|
132
|
-
body: { tenantId, tableId, ...target, changes },
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
case "update-rows": {
|
|
136
|
-
const updates = parseJsonOption<Array<Record<string, unknown>>>(rawArgs, "--updates");
|
|
137
|
-
if (!Array.isArray(updates) || updates.length === 0) {
|
|
138
|
-
throw new Error("--updates must be a non-empty JSON array.");
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
path: "/api/table/update-rows",
|
|
142
|
-
body: { tenantId, tableId, updates },
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
case "delete-row": {
|
|
146
|
-
const target = resolveRowTarget(readOption(rawArgs, "--row"));
|
|
147
|
-
if (!target.rowId && !target.dbKey) {
|
|
148
|
-
throw new Error("--row is required and may be rowId or row dbKey.");
|
|
149
|
-
}
|
|
150
|
-
return {
|
|
151
|
-
path: "/api/table/delete-row",
|
|
152
|
-
body: { tenantId, tableId, ...target },
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
case "delete-rows": {
|
|
156
|
-
const rowIds = parseJsonOption<string[]>(rawArgs, "--row-ids");
|
|
157
|
-
const dbKeys = parseJsonOption<string[]>(rawArgs, "--row-dbkeys");
|
|
158
|
-
if ((!Array.isArray(rowIds) || rowIds.length === 0) && (!Array.isArray(dbKeys) || dbKeys.length === 0)) {
|
|
159
|
-
throw new Error("--row-ids or --row-dbkeys must provide a non-empty JSON array.");
|
|
160
|
-
}
|
|
161
|
-
return {
|
|
162
|
-
path: "/api/table/delete-rows",
|
|
163
|
-
body: {
|
|
164
|
-
tenantId,
|
|
165
|
-
tableId,
|
|
166
|
-
...(Array.isArray(rowIds) && rowIds.length > 0 ? { rowIds } : {}),
|
|
167
|
-
...(Array.isArray(dbKeys) && dbKeys.length > 0 ? { dbKeys } : {}),
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
default:
|
|
172
|
-
throw new Error(`unsupported action: ${action}`);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export async function runTableDataCommand(args: string[], deps: TableMutationDeps = {}) {
|
|
177
|
-
const env = deps.env ?? process.env;
|
|
178
|
-
const output = deps.output ?? process.stdout;
|
|
179
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
180
|
-
if (hasFlag(args, "--help") || hasFlag(args, "-h")) {
|
|
181
|
-
output.write(usage());
|
|
182
|
-
return 0;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const action = (readOption(args, "--action") || "query").trim();
|
|
186
|
-
const outputMode = parseOutputMode(readOption(args, "--output"));
|
|
187
|
-
let tableArg: { tenantId?: string; tableId?: string };
|
|
188
|
-
try {
|
|
189
|
-
tableArg = parseTableArg(readOption(args, "--table"));
|
|
190
|
-
assertTableSchemaWriteAllowed({
|
|
191
|
-
action,
|
|
192
|
-
allowSchemaWrite: hasFlag(args, "--schema-write-ok"),
|
|
193
|
-
});
|
|
194
|
-
} catch (error) {
|
|
195
|
-
output.write(`[nolo] table data failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
196
|
-
return 1;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const authToken = resolveAuthToken(args, env);
|
|
200
|
-
const tenantId = readOption(args, "--tenant-id") || tableArg.tenantId || env.USER_ID || parseJwtTenantId(authToken);
|
|
201
|
-
const tableId = tableArg.tableId;
|
|
202
|
-
const tableDbKey = tenantId && tableId ? `meta-${tenantId}-${tableId}` : "";
|
|
203
|
-
if (!authToken) {
|
|
204
|
-
output.write("[nolo] table data failed: AUTH_TOKEN is required.\n");
|
|
205
|
-
return 1;
|
|
206
|
-
}
|
|
207
|
-
if (!tenantId || !tableId || !tableDbKey) {
|
|
208
|
-
output.write(usage());
|
|
209
|
-
return 1;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const serverUrl = resolveServerUrl(args, env);
|
|
213
|
-
try {
|
|
214
|
-
const tableMeta = await readTableMeta({
|
|
215
|
-
authToken,
|
|
216
|
-
dbKey: tableDbKey,
|
|
217
|
-
fetchImpl,
|
|
218
|
-
serverUrl,
|
|
219
|
-
});
|
|
220
|
-
if (!tableMeta || tableMeta.type !== "table") {
|
|
221
|
-
throw new Error(`table definition not found: ${tableDbKey}`);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const request = buildMutationRequest({
|
|
225
|
-
action,
|
|
226
|
-
rawArgs: args,
|
|
227
|
-
tableId,
|
|
228
|
-
tenantId,
|
|
229
|
-
});
|
|
230
|
-
const result = await postTableAction({
|
|
231
|
-
authToken,
|
|
232
|
-
body: request.body,
|
|
233
|
-
fetchImpl,
|
|
234
|
-
path: request.path,
|
|
235
|
-
serverUrl,
|
|
236
|
-
});
|
|
237
|
-
const envelope = {
|
|
238
|
-
ok: true,
|
|
239
|
-
action,
|
|
240
|
-
baseUrl: serverUrl,
|
|
241
|
-
tenantId,
|
|
242
|
-
tableId,
|
|
243
|
-
tableDbKey,
|
|
244
|
-
tableName: tableMeta.displayName ?? null,
|
|
245
|
-
result,
|
|
246
|
-
};
|
|
247
|
-
output.write(`${formatOutput({ envelope, rawData: result, mode: outputMode })}\n`);
|
|
248
|
-
return 0;
|
|
249
|
-
} catch (error) {
|
|
250
|
-
output.write(`[nolo] table data failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
251
|
-
return 1;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function withAction(action: string) {
|
|
256
|
-
return (args: string[], deps: TableMutationDeps = {}) =>
|
|
257
|
-
runTableDataCommand(["--action", action, ...args], deps);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export const runTableAddColumnCommand = withAction("add-column");
|
|
261
|
-
export const runTableAddRowCommand = withAction("add-row");
|
|
262
|
-
export const runTableAddRowsCommand = withAction("add-rows");
|
|
263
|
-
export const runTableUpdateRowCommand = withAction("update-row");
|
|
264
|
-
export const runTableUpdateRowsCommand = withAction("update-rows");
|
|
265
|
-
export const runTableDeleteRowCommand = withAction("delete-row");
|
|
266
|
-
export const runTableDeleteRowsCommand = withAction("delete-rows");
|
package/tableQueryParsing.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decodeJwtPayload,
|
|
3
|
-
hasFlag as hasCliFlag,
|
|
4
|
-
readCliOptionValue,
|
|
5
|
-
resolveAuthTokenFromArgs,
|
|
6
|
-
resolveServerUrlFromArgs,
|
|
7
|
-
} from "./cliEnvHelpers";
|
|
8
|
-
import {
|
|
9
|
-
formatTableDataOutput,
|
|
10
|
-
parseTableDataOutputMode,
|
|
11
|
-
type TableDataOutputMode,
|
|
12
|
-
} from "./tableDataOutput";
|
|
13
|
-
|
|
14
|
-
export type EnvLike = Record<string, string | undefined>;
|
|
15
|
-
export type OutputMode = TableDataOutputMode;
|
|
16
|
-
|
|
17
|
-
export function readOption(args: string[], flag: string): string {
|
|
18
|
-
return readCliOptionValue(args, flag);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function hasFlag(args: string[], flag: string): boolean {
|
|
22
|
-
return hasCliFlag(args, flag);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function parseJsonOption<T>(args: string[], flag: string): T | undefined {
|
|
26
|
-
const raw = readOption(args, flag);
|
|
27
|
-
if (!raw) return undefined;
|
|
28
|
-
try {
|
|
29
|
-
return JSON.parse(raw) as T;
|
|
30
|
-
} catch (error) {
|
|
31
|
-
throw new Error(`${flag} must be valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function parseJsonOptionAlias<T>(
|
|
36
|
-
args: string[],
|
|
37
|
-
primaryFlag: string,
|
|
38
|
-
aliasFlag: string,
|
|
39
|
-
): T | undefined {
|
|
40
|
-
const primary = readOption(args, primaryFlag);
|
|
41
|
-
const alias = readOption(args, aliasFlag);
|
|
42
|
-
const raw = primary || alias;
|
|
43
|
-
if (!raw) return undefined;
|
|
44
|
-
try {
|
|
45
|
-
return JSON.parse(raw) as T;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
const usedFlag = primary ? primaryFlag : aliasFlag;
|
|
48
|
-
throw new Error(`${usedFlag} must be valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function parseOutputMode(raw: string): OutputMode {
|
|
53
|
-
return parseTableDataOutputMode(raw);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function parseTableArg(raw: string): { tenantId?: string; tableId?: string } {
|
|
57
|
-
const trimmed = raw.trim();
|
|
58
|
-
if (!trimmed) return {};
|
|
59
|
-
if (!trimmed.startsWith("meta-")) return { tableId: trimmed };
|
|
60
|
-
const parts = trimmed.split("-");
|
|
61
|
-
return {
|
|
62
|
-
tenantId: parts[1],
|
|
63
|
-
tableId: parts.slice(2).join("-"),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function resolveServerUrl(args: string[], env: EnvLike): string {
|
|
68
|
-
return resolveServerUrlFromArgs(args, env);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function resolveAuthToken(args: string[], env: EnvLike): string {
|
|
72
|
-
return resolveAuthTokenFromArgs(args, env);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function parseJwtTenantId(token: string): string | undefined {
|
|
76
|
-
const parsed = decodeJwtPayload(token);
|
|
77
|
-
return typeof parsed?.userId === "string"
|
|
78
|
-
? parsed.userId
|
|
79
|
-
: typeof parsed?.sub === "string"
|
|
80
|
-
? parsed.sub
|
|
81
|
-
: undefined;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function formatOutput(input: { envelope: any; rawData: any; mode: OutputMode }): string {
|
|
85
|
-
return formatTableDataOutput({
|
|
86
|
-
envelope: input.envelope,
|
|
87
|
-
result: input.rawData,
|
|
88
|
-
mode: input.mode,
|
|
89
|
-
});
|
|
90
|
-
}
|
package/tableQueryRequest.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { includeTableActivityColumns } from "./render/table/activityColumns";
|
|
2
|
-
import { readOption } from "./tableQueryParsing";
|
|
3
|
-
|
|
4
|
-
export type TableQueryFilters = Record<string, unknown>;
|
|
5
|
-
|
|
6
|
-
export type TableQueryRequestInput = {
|
|
7
|
-
tenantId: string;
|
|
8
|
-
tableId: string;
|
|
9
|
-
filters?: TableQueryFilters;
|
|
10
|
-
columns?: string[];
|
|
11
|
-
includeActivity?: boolean;
|
|
12
|
-
includeBaseFields?: boolean;
|
|
13
|
-
hasSingleRowShortcut?: boolean;
|
|
14
|
-
limit?: string | number;
|
|
15
|
-
offset?: string | number;
|
|
16
|
-
sortBy?: string;
|
|
17
|
-
sortOrder?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function mergeQueryShortcutFilters(
|
|
21
|
-
args: string[],
|
|
22
|
-
filters: TableQueryFilters | undefined,
|
|
23
|
-
): TableQueryFilters | undefined {
|
|
24
|
-
const row = readOption(args, "--row") || readOption(args, "--row-id");
|
|
25
|
-
const rowDbKey = readOption(args, "--row-dbkey");
|
|
26
|
-
const shortcutFilters: TableQueryFilters = {};
|
|
27
|
-
if (row) {
|
|
28
|
-
if (row.startsWith("row-")) shortcutFilters.dbKey = row;
|
|
29
|
-
else shortcutFilters.rowId = row;
|
|
30
|
-
}
|
|
31
|
-
if (rowDbKey) shortcutFilters.dbKey = rowDbKey;
|
|
32
|
-
if (Object.keys(shortcutFilters).length === 0) return filters;
|
|
33
|
-
return {
|
|
34
|
-
...(filters ?? {}),
|
|
35
|
-
...shortcutFilters,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function buildTableQueryRequest(input: TableQueryRequestInput) {
|
|
40
|
-
return {
|
|
41
|
-
tenantId: input.tenantId,
|
|
42
|
-
tableId: input.tableId,
|
|
43
|
-
filters: input.filters ?? {},
|
|
44
|
-
columns: input.includeActivity
|
|
45
|
-
? includeTableActivityColumns(input.columns)
|
|
46
|
-
: input.columns,
|
|
47
|
-
includeBaseFields: input.includeBaseFields ?? true,
|
|
48
|
-
limit: Number(input.limit || (input.hasSingleRowShortcut ? 1 : 20)),
|
|
49
|
-
offset: Number(input.offset || 0),
|
|
50
|
-
sortBy: input.sortBy || "updatedAt",
|
|
51
|
-
sortOrder: input.sortOrder === "asc" ? "asc" : "desc",
|
|
52
|
-
};
|
|
53
|
-
}
|
package/taskRunActions.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { csv, optional, optionalJson, required } from "./taskRunParsing";
|
|
2
|
-
|
|
3
|
-
export function buildBody(command: string, args: string[]) {
|
|
4
|
-
const dbKey = required(args, "--row-dbkey");
|
|
5
|
-
if (command === "read-context" || command === "readTaskContext") {
|
|
6
|
-
return { action: "readTaskContext", dbKey };
|
|
7
|
-
}
|
|
8
|
-
if (command === "claim-work-item" || command === "claimWorkItem") {
|
|
9
|
-
return {
|
|
10
|
-
action: "claimWorkItem",
|
|
11
|
-
dbKey,
|
|
12
|
-
workItemId: required(args, "--work-item-id"),
|
|
13
|
-
agentKey: required(args, "--agent-key"),
|
|
14
|
-
role: optional(args, "--role"),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (command === "record-agent-run" || command === "recordAgentRun") {
|
|
18
|
-
const toolTraceSummary = optionalJson(args, "--tool-trace-summary");
|
|
19
|
-
return {
|
|
20
|
-
action: "recordAgentRun",
|
|
21
|
-
dbKey,
|
|
22
|
-
...(optional(args, "--run-id") ? { runId: optional(args, "--run-id") } : {}),
|
|
23
|
-
agentKey: required(args, "--agent-key"),
|
|
24
|
-
...(optional(args, "--role") ? { role: optional(args, "--role") } : {}),
|
|
25
|
-
runStatus: required(args, "--run-status"),
|
|
26
|
-
...(optional(args, "--work-item-id") ? { workItemId: optional(args, "--work-item-id") } : {}),
|
|
27
|
-
...(optional(args, "--dialog-id") ? { dialogId: optional(args, "--dialog-id") } : {}),
|
|
28
|
-
...(optional(args, "--result-summary") ? { resultSummary: optional(args, "--result-summary") } : {}),
|
|
29
|
-
...(optional(args, "--error-code") ? { errorCode: optional(args, "--error-code") } : {}),
|
|
30
|
-
...(optional(args, "--tools-used") ? { toolsUsed: csv(optional(args, "--tools-used")!) } : {}),
|
|
31
|
-
...(toolTraceSummary ? { toolTraceSummary } : {}),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
if (command === "set-blocker" || command === "setBlocker") {
|
|
35
|
-
return {
|
|
36
|
-
action: "setBlocker",
|
|
37
|
-
dbKey,
|
|
38
|
-
workItemId: optional(args, "--work-item-id"),
|
|
39
|
-
blocker: {
|
|
40
|
-
layer: required(args, "--layer"),
|
|
41
|
-
code: required(args, "--code"),
|
|
42
|
-
message: required(args, "--message"),
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if (command === "clear-blocker" || command === "clearBlocker") {
|
|
47
|
-
return {
|
|
48
|
-
action: "clearBlocker",
|
|
49
|
-
dbKey,
|
|
50
|
-
blockerId: required(args, "--blocker-id"),
|
|
51
|
-
workItemId: optional(args, "--work-item-id"),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
if (command === "submit-outcome" || command === "submitOutcome") {
|
|
55
|
-
return {
|
|
56
|
-
action: "submitOutcome",
|
|
57
|
-
dbKey,
|
|
58
|
-
workItemId: required(args, "--work-item-id"),
|
|
59
|
-
summary: required(args, "--summary"),
|
|
60
|
-
...(optional(args, "--dialog-id") ? { dialogId: optional(args, "--dialog-id") } : {}),
|
|
61
|
-
...(optional(args, "--artifact-ids") ? { artifactIds: csv(optional(args, "--artifact-ids")!) } : {}),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
if (command === "request-review" || command === "requestReview") {
|
|
65
|
-
return {
|
|
66
|
-
action: "requestReview",
|
|
67
|
-
dbKey,
|
|
68
|
-
workItemId: optional(args, "--work-item-id"),
|
|
69
|
-
reviewerAgentKey: required(args, "--reviewer-agent-key"),
|
|
70
|
-
...(optional(args, "--dialog-id") ? { dialogId: optional(args, "--dialog-id") } : {}),
|
|
71
|
-
...(optional(args, "--message") ? { message: optional(args, "--message") } : {}),
|
|
72
|
-
...(optional(args, "--artifact-ids") ? { artifactIds: csv(optional(args, "--artifact-ids")!) } : {}),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (command === "record-review" || command === "recordReview") {
|
|
76
|
-
return {
|
|
77
|
-
action: "recordReview",
|
|
78
|
-
dbKey,
|
|
79
|
-
...(optional(args, "--work-item-id") ? { workItemId: optional(args, "--work-item-id") } : {}),
|
|
80
|
-
reviewStatus: required(args, "--review-status"),
|
|
81
|
-
...(optional(args, "--reviewer-agent-key")
|
|
82
|
-
? { reviewerAgentKey: optional(args, "--reviewer-agent-key") }
|
|
83
|
-
: {}),
|
|
84
|
-
...(optional(args, "--dialog-id") ? { dialogId: optional(args, "--dialog-id") } : {}),
|
|
85
|
-
...(optional(args, "--findings") ? { findings: optional(args, "--findings") } : {}),
|
|
86
|
-
...(optional(args, "--artifact-ids") ? { artifactIds: csv(optional(args, "--artifact-ids")!) } : {}),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
if (
|
|
90
|
-
command === "close-work-item" ||
|
|
91
|
-
command === "complete-work-item" ||
|
|
92
|
-
command === "closeWorkItem" ||
|
|
93
|
-
command === "completeWorkItem"
|
|
94
|
-
) {
|
|
95
|
-
return {
|
|
96
|
-
action: "closeWorkItem",
|
|
97
|
-
dbKey,
|
|
98
|
-
workItemId: required(args, "--work-item-id"),
|
|
99
|
-
summary: required(args, "--summary"),
|
|
100
|
-
...(optional(args, "--reason") ? { reason: optional(args, "--reason") } : {}),
|
|
101
|
-
...(optional(args, "--dialog-id") ? { dialogId: optional(args, "--dialog-id") } : {}),
|
|
102
|
-
...(optional(args, "--artifact-ids") ? { artifactIds: csv(optional(args, "--artifact-ids")!) } : {}),
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
throw new Error(`Unknown task-run command: ${command}`);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function usage() {
|
|
109
|
-
return [
|
|
110
|
-
"Usage:",
|
|
111
|
-
" nolo task-run read-context --row-dbkey <row>",
|
|
112
|
-
" nolo task-run claim-work-item --row-dbkey <row> --work-item-id <id> --agent-key <agent> [--role <role>]",
|
|
113
|
-
" nolo task-run record-agent-run --row-dbkey <row> --agent-key <agent> --run-status <status> [--tools-used <csv>]",
|
|
114
|
-
" nolo task-run set-blocker --row-dbkey <row> [--work-item-id <id>] --layer <layer> --code <code> --message <message>",
|
|
115
|
-
" nolo task-run clear-blocker --row-dbkey <row> --blocker-id <id> [--work-item-id <id>]",
|
|
116
|
-
" nolo task-run submit-outcome --row-dbkey <row> --work-item-id <id> --summary <summary> [--dialog-id <id>]",
|
|
117
|
-
" nolo task-run request-review --row-dbkey <row> --reviewer-agent-key <agent> [--work-item-id <id>]",
|
|
118
|
-
" nolo task-run record-review --row-dbkey <row> [--work-item-id <id>] --review-status <passed|needs_changes|blocked> [--findings <text>]",
|
|
119
|
-
" nolo task-run close-work-item --row-dbkey <row> --work-item-id <id> --summary <summary>",
|
|
120
|
-
"",
|
|
121
|
-
].join("\n");
|
|
122
|
-
}
|
package/taskRunParsing.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
readCliOptionValue,
|
|
7
|
-
resolveAuthTokenFromArgs,
|
|
8
|
-
resolveServerUrlFromArgs,
|
|
9
|
-
} from "./cliEnvHelpers";
|
|
10
|
-
|
|
11
|
-
export type EnvLike = Record<string, string | undefined>;
|
|
12
|
-
|
|
13
|
-
export function parseEnvFile(path: string): EnvLike {
|
|
14
|
-
if (!path || !existsSync(path)) return {};
|
|
15
|
-
const parsed: EnvLike = {};
|
|
16
|
-
for (const rawLine of readFileSync(path, "utf8").split(/\r?\n/)) {
|
|
17
|
-
const line = rawLine.trim();
|
|
18
|
-
if (!line || line.startsWith("#")) continue;
|
|
19
|
-
const index = line.indexOf("=");
|
|
20
|
-
if (index <= 0) continue;
|
|
21
|
-
const key = line.slice(0, index).trim();
|
|
22
|
-
let value = line.slice(index + 1).trim();
|
|
23
|
-
if (
|
|
24
|
-
(value.startsWith('"') && value.endsWith('"')) ||
|
|
25
|
-
(value.startsWith("'") && value.endsWith("'"))
|
|
26
|
-
) {
|
|
27
|
-
value = value.slice(1, -1);
|
|
28
|
-
}
|
|
29
|
-
if (key) parsed[key] = value;
|
|
30
|
-
}
|
|
31
|
-
return parsed;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function loadTaskRunEnv(
|
|
35
|
-
env: EnvLike,
|
|
36
|
-
options: { includeDefaultEnvFiles?: boolean } = {},
|
|
37
|
-
) {
|
|
38
|
-
const envFileCandidates = [
|
|
39
|
-
env.NOLO_TASK_RUN_ENV_FILE,
|
|
40
|
-
env.NOLO_MACHINE_ENV_FILE,
|
|
41
|
-
...(options.includeDefaultEnvFiles
|
|
42
|
-
? ["/etc/nolo/machine-runner.env", join(homedir(), ".nolo", "machine-runner.env")]
|
|
43
|
-
: []),
|
|
44
|
-
].filter((path): path is string => Boolean(path));
|
|
45
|
-
const fileEnv = Object.assign({}, ...envFileCandidates.map(parseEnvFile));
|
|
46
|
-
return { ...fileEnv, ...env };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function readOption(args: string[], flag: string) {
|
|
50
|
-
return readCliOptionValue(args, flag);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function csv(raw: string) {
|
|
54
|
-
return raw.split(",").map((item) => item.trim()).filter(Boolean);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function required(args: string[], flag: string) {
|
|
58
|
-
const value = readOption(args, flag).trim();
|
|
59
|
-
if (!value) throw new Error(`${flag} is required`);
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function optional(args: string[], flag: string) {
|
|
64
|
-
const value = readOption(args, flag).trim();
|
|
65
|
-
return value || undefined;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function optionalJson(args: string[], flag: string) {
|
|
69
|
-
const value = optional(args, flag);
|
|
70
|
-
if (!value) return undefined;
|
|
71
|
-
try {
|
|
72
|
-
return JSON.parse(value);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
throw new Error(
|
|
75
|
-
`${flag} must be valid JSON: ${error instanceof Error ? error.message : String(error)}`,
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function resolveServerUrl(args: string[], env: EnvLike) {
|
|
81
|
-
return resolveServerUrlFromArgs(args, env);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function resolveAuthToken(args: string[], env: EnvLike) {
|
|
85
|
-
return resolveAuthTokenFromArgs(args, env);
|
|
86
|
-
}
|
package/taskRunPromptShared.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export type TaskRunPromptContext = {
|
|
2
|
-
rowDbKey: string;
|
|
3
|
-
taskRunId?: string;
|
|
4
|
-
workItemId?: string;
|
|
5
|
-
artifactIds?: string[];
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type TaskRunPromptRuntime = "cli" | "server-tool";
|
|
9
|
-
|
|
10
|
-
function buildTaskRunPromptRuntimeLines(runtime: TaskRunPromptRuntime): string[] {
|
|
11
|
-
if (runtime === "cli") {
|
|
12
|
-
return [
|
|
13
|
-
"- When you create, update, hand off, block, or review work, update the task context with `bun run task:run -- ...`.",
|
|
14
|
-
"- If this turn already includes a server TaskRun preflight snapshot, use that snapshot directly for read-only reporting or planning.",
|
|
15
|
-
];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return [
|
|
19
|
-
"- Use the server-side `taskRun` tool when you create, update, hand off, block, or review work.",
|
|
20
|
-
"- If this turn already includes a server TaskRun preflight snapshot, use that snapshot directly for read-only reporting or planning. Otherwise start with `readTaskContext`.",
|
|
21
|
-
"- Use primitive actions such as `upsertWorkItem`, `claimWorkItem`, `openDialog`, `setBlocker`, `requestReview`, `recordReview`, `submitOutcome`, and `closeWorkItem`.",
|
|
22
|
-
"- Do not emulate `taskRun` by directly editing `meta.taskRun` with table tools. Table tools are only for human-readable columns such as status, progress, and result.",
|
|
23
|
-
"- Do not delegate `taskRun` state writes through `streamParallelAgents`. The coordinating agent must write task-run state itself, then delegate implementation or review work if needed.",
|
|
24
|
-
"- If the `taskRun` tool is not exposed at runtime, report that as an infrastructure blocker instead of inventing a compatible-looking meta shape.",
|
|
25
|
-
"- Keep actions generic and configurable. Do not invent hardcoded workflow verbs like `handoff_frontend` when an `openDialog` or work item update is enough.",
|
|
26
|
-
];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function buildTaskRunPromptBlock(
|
|
30
|
-
context: TaskRunPromptContext,
|
|
31
|
-
runtime: TaskRunPromptRuntime
|
|
32
|
-
): string {
|
|
33
|
-
const artifactIds = context.artifactIds?.filter(Boolean) ?? [];
|
|
34
|
-
return [
|
|
35
|
-
"AI-native task-run context:",
|
|
36
|
-
"- This system is AI-native. The current task board is only the present observation and validation use case; different users, companies, and workflows may use different task owners later.",
|
|
37
|
-
"- Treat the task row meta as the durable execution context. Do not infer branch, runner, handoff, review, or blocker state from chat history alone.",
|
|
38
|
-
`- rowDbKey: ${context.rowDbKey}`,
|
|
39
|
-
...(context.taskRunId ? [`- taskRunId: ${context.taskRunId}`] : []),
|
|
40
|
-
...(context.workItemId ? [`- workItemId: ${context.workItemId}`] : []),
|
|
41
|
-
...(artifactIds.length ? [`- artifactIds: ${artifactIds.join(",")}`] : []),
|
|
42
|
-
"- Handoff rule: start from the durable task context, then inspect existing refs such as workItems.dialogIds, workItems.outcome, review.dialogId, activityRefs, agentRuns.dialogId/resultSummary, and artifactRefs. Use dialog read/search for exact evidence.",
|
|
43
|
-
...buildTaskRunPromptRuntimeLines(runtime),
|
|
44
|
-
"- Keep long reasoning and logs in the dialog; record only resumable references in task row meta.",
|
|
45
|
-
].join("\n");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function prependTaskRunPromptForRuntime(
|
|
49
|
-
message: string,
|
|
50
|
-
context: TaskRunPromptContext | undefined,
|
|
51
|
-
runtime: TaskRunPromptRuntime
|
|
52
|
-
): string {
|
|
53
|
-
if (!context?.rowDbKey) return message;
|
|
54
|
-
return `${buildTaskRunPromptBlock(context, runtime)}\n\nUser task:\n${message}`;
|
|
55
|
-
}
|