maka-agent 0.2.0-dev.25.20260908 → 0.2.0-dev.26.20260909
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/dist/mcp-capability-provider.js +4 -1
- package/dist/pi-tui-mcp-status.js +2 -2
- package/dist/pi-tui-pickers.js +19 -29
- package/dist/tui-autocomplete-layout.js +3 -1
- package/dist/tui-copy-catalog.js +6 -3
- package/dist/tui-editor-render.js +36 -0
- package/dist/tui-mcp-control.js +41 -6
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/runtime-event.js +3 -0
- package/node_modules/@maka/core/dist/session.js +29 -4
- package/node_modules/@maka/core/dist/workhub-action-result.js +68 -0
- package/node_modules/@maka/core/package.json +2 -3
- package/node_modules/@maka/eval/dist/toolchain-verification.js +1 -1
- package/node_modules/@maka/mcp/dist/form-elicitation.js +213 -0
- package/node_modules/@maka/mcp/dist/index.js +337 -71
- package/node_modules/@maka/runtime/dist/agent-run.js +10 -1
- package/node_modules/@maka/runtime/dist/goal-continuation.js +5 -1
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +20 -1
- package/node_modules/@maka/runtime/dist/runtime-kernel.js +120 -13
- package/node_modules/@maka/runtime/dist/session-manager.js +20 -36
- package/node_modules/@maka/runtime-host/dist/client/connection.js +30 -5
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +17 -1
- package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +4 -2
- package/node_modules/@maka/runtime-host/dist/client/peer-client.js +18 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +3 -2
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +68 -168
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +2 -1
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +28 -8
- package/node_modules/@maka/runtime-host/dist/server/daily-review-coordinator.js +112 -56
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +45 -20
- package/node_modules/@maka/runtime-host/dist/server/failure-diagnostic.js +24 -0
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +7 -3
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +3 -3
- package/node_modules/@maka/runtime-host/dist/server/host-session-availability.js +5 -2
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +34 -4
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +4 -1
- package/node_modules/@maka/runtime-host/dist/server/operation-dispatcher.js +2 -7
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +110 -14
- package/node_modules/@maka/runtime-host/dist/server/runtime-resource-coordinator.js +11 -8
- package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +31 -21
- package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +20 -8
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +15 -104
- package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +44 -85
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +120 -137
- package/node_modules/@maka/storage/dist/agent-run-store.js +14 -1
- package/node_modules/@maka/storage/dist/artifact-store.js +40 -3
- package/node_modules/@maka/storage/dist/atomic-file-write.js +74 -0
- package/node_modules/@maka/storage/dist/credential-store.js +12 -63
- package/node_modules/@maka/storage/dist/execution-stores.js +4 -1
- package/node_modules/@maka/storage/dist/mcp-config-store.js +10 -25
- package/node_modules/@maka/storage/dist/session-store.js +14 -2
- package/node_modules/@maka/storage/dist/settings-store.js +8 -4
- package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +11 -0
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +12 -1
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +67 -3
- package/node_modules/@maka/storage/dist/stable-storage.js +14 -1
- package/package.json +1 -1
- package/node_modules/@maka/core/dist/workhub-creation-intent.js +0 -990
- package/node_modules/@maka/core/dist/workhub-session-resolver.js +0 -50
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { decodeInteractionAnswer, decodeInteractionRequest, interactionFormAnswerMatchesRequest, projectInteractionFormRequest, } from '@maka/core/interaction';
|
|
20
|
+
// Unbounded protocol strings need a visible client input limit: Core reserves
|
|
21
|
+
// the worst-case JSON-escaped answer within its serialized interaction budget.
|
|
22
|
+
// Explicit server bounds are preserved and still checked by Core admission.
|
|
23
|
+
const DEFAULT_STRING_MAX_LENGTH = 256;
|
|
24
|
+
/** Inspect raw keys and values before projection can escape control characters.
|
|
25
|
+
* This is a containment check, not a comparison with redacted output: a state
|
|
26
|
+
* may itself be identical to the redaction marker.
|
|
27
|
+
*/
|
|
28
|
+
export function containsMcpFormState(value, states) {
|
|
29
|
+
const pending = [value];
|
|
30
|
+
while (pending.length) {
|
|
31
|
+
const item = pending.pop();
|
|
32
|
+
if (typeof item === 'string') {
|
|
33
|
+
if (states.some((state) => state.length > 0 && item.includes(state)))
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
else if (item !== null && typeof item === 'object') {
|
|
37
|
+
for (const [key, child] of Object.entries(item))
|
|
38
|
+
pending.push(key, child);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
function record(value) {
|
|
44
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
45
|
+
throw new Error();
|
|
46
|
+
const prototype = Object.getPrototypeOf(value);
|
|
47
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
48
|
+
throw new Error();
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
function keys(value, allowed) {
|
|
52
|
+
if (Object.keys(value).some((key) => !allowed.includes(key)))
|
|
53
|
+
throw new Error();
|
|
54
|
+
}
|
|
55
|
+
function select(value, names) {
|
|
56
|
+
return Object.fromEntries(names.filter((name) => Object.hasOwn(value, name)).map((name) => [name, value[name]]));
|
|
57
|
+
}
|
|
58
|
+
function options(value, titles) {
|
|
59
|
+
if (!Array.isArray(value) ||
|
|
60
|
+
(titles !== undefined && (!Array.isArray(titles) || titles.length !== value.length)))
|
|
61
|
+
throw new Error();
|
|
62
|
+
return value.map((entry, index) => ({
|
|
63
|
+
value: entry,
|
|
64
|
+
label: Array.isArray(titles) ? titles[index] : entry,
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
function titledOptions(value) {
|
|
68
|
+
if (!Array.isArray(value))
|
|
69
|
+
throw new Error();
|
|
70
|
+
return value.map((entry) => {
|
|
71
|
+
const option = record(entry);
|
|
72
|
+
keys(option, ['const', 'title']);
|
|
73
|
+
return { value: option.const, label: option.title };
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function field(name, value, required) {
|
|
77
|
+
const schema = record(value);
|
|
78
|
+
const sharedKeys = ['type', 'title', 'description', 'default'];
|
|
79
|
+
const shared = {
|
|
80
|
+
name,
|
|
81
|
+
label: Object.hasOwn(schema, 'title') ? schema.title : name,
|
|
82
|
+
required,
|
|
83
|
+
...select(schema, ['description', 'default']),
|
|
84
|
+
};
|
|
85
|
+
if (schema.type === 'string') {
|
|
86
|
+
if (Object.hasOwn(schema, 'enum')) {
|
|
87
|
+
keys(schema, [...sharedKeys, 'enum', 'enumNames']);
|
|
88
|
+
return { ...shared, kind: 'single_select', options: options(schema.enum, schema.enumNames) };
|
|
89
|
+
}
|
|
90
|
+
if (Object.hasOwn(schema, 'oneOf')) {
|
|
91
|
+
keys(schema, [...sharedKeys, 'oneOf']);
|
|
92
|
+
return { ...shared, kind: 'single_select', options: titledOptions(schema.oneOf) };
|
|
93
|
+
}
|
|
94
|
+
keys(schema, [...sharedKeys, 'minLength', 'maxLength', 'format']);
|
|
95
|
+
return {
|
|
96
|
+
...shared,
|
|
97
|
+
kind: 'string',
|
|
98
|
+
...select(schema, ['minLength', 'maxLength', 'format']),
|
|
99
|
+
...(schema.maxLength === undefined ? { maxLength: DEFAULT_STRING_MAX_LENGTH } : {}),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (schema.type === 'number' || schema.type === 'integer') {
|
|
103
|
+
keys(schema, [...sharedKeys, 'minimum', 'maximum']);
|
|
104
|
+
// Core validates numeric ranges; an integer-only interval may additionally be empty.
|
|
105
|
+
if (schema.type === 'integer' &&
|
|
106
|
+
typeof schema.minimum === 'number' &&
|
|
107
|
+
typeof schema.maximum === 'number' &&
|
|
108
|
+
Math.ceil(schema.minimum) > Math.floor(schema.maximum))
|
|
109
|
+
throw new Error();
|
|
110
|
+
return { ...shared, kind: schema.type, ...select(schema, ['minimum', 'maximum']) };
|
|
111
|
+
}
|
|
112
|
+
if (schema.type === 'boolean') {
|
|
113
|
+
keys(schema, sharedKeys);
|
|
114
|
+
return { ...shared, kind: 'boolean' };
|
|
115
|
+
}
|
|
116
|
+
if (schema.type === 'array') {
|
|
117
|
+
keys(schema, [...sharedKeys, 'items', 'minItems', 'maxItems']);
|
|
118
|
+
const items = record(schema.items);
|
|
119
|
+
let choices;
|
|
120
|
+
if (Object.hasOwn(items, 'anyOf')) {
|
|
121
|
+
keys(items, ['anyOf']);
|
|
122
|
+
choices = titledOptions(items.anyOf);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
keys(items, ['type', 'enum']);
|
|
126
|
+
if (items.type !== 'string')
|
|
127
|
+
throw new Error();
|
|
128
|
+
choices = options(items.enum);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
...shared,
|
|
132
|
+
kind: 'multi_select',
|
|
133
|
+
options: choices,
|
|
134
|
+
...select(schema, ['minItems', 'maxItems']),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
throw new Error();
|
|
138
|
+
}
|
|
139
|
+
/** Adapt one embedded MCP form request without exposing protocol state to the UI. */
|
|
140
|
+
export function prepareMcpForm(request, requester) {
|
|
141
|
+
try {
|
|
142
|
+
const embedded = record(request);
|
|
143
|
+
keys(embedded, ['method', 'params']);
|
|
144
|
+
if (embedded.method !== 'elicitation/create')
|
|
145
|
+
throw new Error();
|
|
146
|
+
const params = record(embedded.params);
|
|
147
|
+
keys(params, ['mode', 'message', 'requestedSchema', '_meta']);
|
|
148
|
+
if (params.mode !== undefined && params.mode !== 'form')
|
|
149
|
+
throw new Error();
|
|
150
|
+
const schema = record(params.requestedSchema);
|
|
151
|
+
keys(schema, [
|
|
152
|
+
'type',
|
|
153
|
+
'properties',
|
|
154
|
+
'required',
|
|
155
|
+
'$schema',
|
|
156
|
+
'title',
|
|
157
|
+
'description',
|
|
158
|
+
'additionalProperties',
|
|
159
|
+
]);
|
|
160
|
+
if (schema.type !== 'object' ||
|
|
161
|
+
(schema.additionalProperties !== undefined && schema.additionalProperties !== false))
|
|
162
|
+
throw new Error();
|
|
163
|
+
for (const annotation of ['$schema', 'title', 'description']) {
|
|
164
|
+
if (schema[annotation] !== undefined && typeof schema[annotation] !== 'string')
|
|
165
|
+
throw new Error();
|
|
166
|
+
}
|
|
167
|
+
const properties = record(schema.properties);
|
|
168
|
+
const required = schema.required === undefined ? [] : schema.required;
|
|
169
|
+
if (!Array.isArray(required) ||
|
|
170
|
+
required.some((name) => typeof name !== 'string' || !Object.hasOwn(properties, name)) ||
|
|
171
|
+
new Set(required).size !== required.length)
|
|
172
|
+
throw new Error();
|
|
173
|
+
const decoded = decodeInteractionRequest({
|
|
174
|
+
kind: 'form',
|
|
175
|
+
toolUseId: 'mcp-form',
|
|
176
|
+
message: params.message,
|
|
177
|
+
requester,
|
|
178
|
+
fields: Object.entries(properties).map(([name, schema]) => field(name, schema, required.includes(name))),
|
|
179
|
+
});
|
|
180
|
+
if (decoded.kind !== 'form')
|
|
181
|
+
throw new Error();
|
|
182
|
+
const projected = projectInteractionFormRequest(decoded);
|
|
183
|
+
return {
|
|
184
|
+
form: {
|
|
185
|
+
message: projected.message,
|
|
186
|
+
requester: projected.requester,
|
|
187
|
+
fields: projected.fields,
|
|
188
|
+
},
|
|
189
|
+
respond(result) {
|
|
190
|
+
try {
|
|
191
|
+
const answer = decodeInteractionAnswer({ ...result, kind: 'form' });
|
|
192
|
+
if (answer.kind !== 'form' || !interactionFormAnswerMatchesRequest(projected, answer))
|
|
193
|
+
throw new Error();
|
|
194
|
+
if (answer.action !== 'accept')
|
|
195
|
+
return { action: answer.action };
|
|
196
|
+
return {
|
|
197
|
+
action: 'accept',
|
|
198
|
+
content: Object.fromEntries(Object.entries(answer.values).map(([name, value]) => [
|
|
199
|
+
name,
|
|
200
|
+
typeof value === 'object' ? [...value] : value,
|
|
201
|
+
])),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
throw new Error('Invalid MCP form response');
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
throw new Error('Unsupported or invalid MCP form request');
|
|
212
|
+
}
|
|
213
|
+
}
|