@xpert-ai/plugin-sdk 3.27.0 → 3.28.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/collaboration-client.cjs.js +31 -5
- package/collaboration-client.esm.js +31 -5
- package/index.cjs.js +310 -45
- package/index.esm.js +303 -47
- package/model-provider.cjs.js +2 -1
- package/model-provider.esm.js +2 -1
- package/package.json +2 -2
- package/src/index.d.ts +1 -0
- package/src/lib/agent/handoff/types.d.ts +5 -0
- package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +6 -1
- package/src/lib/agent/runtime/capability.d.ts +4 -0
- package/src/lib/agent/runtime/cli-model-profile.d.ts +1 -1
- package/src/lib/agent/runtime/execution-runner.d.ts +11 -0
- package/src/lib/agent/runtime/index.d.ts +2 -0
- package/src/lib/agent/runtime/managed.d.ts +94 -0
- package/src/lib/agent/runtime/process-supervisor.d.ts +1 -0
- package/src/lib/agent/runtime/strategy.d.ts +14 -0
- package/src/lib/agent/runtime/types.d.ts +30 -1
- package/src/lib/ai-model/native-model.d.ts +5 -1
- package/src/lib/assistant-capability/index.d.ts +1 -0
- package/src/lib/assistant-capability/middleware.d.ts +10 -0
- package/src/lib/collaboration/types.d.ts +5 -0
- package/src/lib/content-resource/catalog.d.ts +88 -0
- package/src/lib/content-resource/editor-compatibility.d.ts +3 -0
- package/src/lib/content-resource/editor.d.ts +35 -3
- package/src/lib/content-resource/index.d.ts +3 -0
- package/src/lib/execution-control/context.d.ts +7 -0
- package/src/lib/execution-control/index.d.ts +2 -0
- package/src/lib/managed-queue/index.d.ts +12 -0
- package/src/lib/runtime/capabilities/artifact-drafts.d.ts +10 -1
- package/src/lib/runtime/capabilities/mcp-client-runtime.d.ts +2 -0
- package/src/lib/runtime/capabilities/sandbox-jobs.d.ts +12 -3
- package/src/lib/sandbox/file-edit-command.d.ts +2 -0
- package/src/lib/sandbox/file-edit-diff.d.ts +1 -0
- package/src/lib/sandbox/protocol.d.ts +13 -1
- package/src/lib/sandbox/runtime-provider.d.ts +12 -0
|
@@ -113,6 +113,8 @@ function createSocketIoTransportAdapter(socket) {
|
|
|
113
113
|
var _options_initialPresence;
|
|
114
114
|
let presence = _extends._extends({}, (_options_initialPresence = options.initialPresence) != null ? _options_initialPresence : {});
|
|
115
115
|
let pending = [];
|
|
116
|
+
let inFlight = [];
|
|
117
|
+
let synchronized = false;
|
|
116
118
|
let flushTimer;
|
|
117
119
|
let syncTimer;
|
|
118
120
|
let presenceTimer;
|
|
@@ -128,9 +130,12 @@ function createSocketIoTransportAdapter(socket) {
|
|
|
128
130
|
const flush = ()=>{
|
|
129
131
|
if (flushTimer) clearTimeout(flushTimer);
|
|
130
132
|
flushTimer = undefined;
|
|
131
|
-
if (!pending.length || !options.transport.connected) return;
|
|
133
|
+
if (!pending.length || inFlight.length || !synchronized || !options.transport.connected) return;
|
|
132
134
|
const updates = pending;
|
|
133
135
|
pending = [];
|
|
136
|
+
// Keep bytes until the server acknowledges persistence. Replaying a Yjs update
|
|
137
|
+
// after a lost acknowledgement is idempotent; dropping it could lose an edit.
|
|
138
|
+
inFlight = updates;
|
|
134
139
|
options.transport.emit('update', {
|
|
135
140
|
updateBase64: bytesToBase64(options.document.mergeUpdates(updates)),
|
|
136
141
|
origin: 'plugin-client'
|
|
@@ -159,23 +164,44 @@ function createSocketIoTransportAdapter(socket) {
|
|
|
159
164
|
started = true;
|
|
160
165
|
options.onConnectionChange == null ? void 0 : options.onConnectionChange.call(options, 'connecting');
|
|
161
166
|
cleanups.push(options.document.onUpdate((update, origin)=>{
|
|
162
|
-
if (origin === remoteOrigin) return;
|
|
167
|
+
if (origin === remoteOrigin || options.session.access !== 'write') return;
|
|
163
168
|
pending.push(update);
|
|
164
169
|
if (!flushTimer) flushTimer = setTimeout(flush, batchMs);
|
|
165
170
|
}));
|
|
166
171
|
cleanups.push(options.transport.on('connect', ()=>{
|
|
172
|
+
synchronized = false;
|
|
167
173
|
var _options_transport_clientId;
|
|
168
174
|
selfClientId = (_options_transport_clientId = options.transport.clientId) != null ? _options_transport_clientId : selfClientId;
|
|
169
175
|
options.onConnectionChange == null ? void 0 : options.onConnectionChange.call(options, 'connected');
|
|
170
176
|
requestSync();
|
|
171
177
|
emitPresence();
|
|
172
178
|
}));
|
|
173
|
-
cleanups.push(options.transport.on('disconnect', ()=>
|
|
174
|
-
|
|
179
|
+
cleanups.push(options.transport.on('disconnect', ()=>{
|
|
180
|
+
synchronized = false;
|
|
181
|
+
pending = [
|
|
182
|
+
...inFlight,
|
|
183
|
+
...pending
|
|
184
|
+
];
|
|
185
|
+
inFlight = [];
|
|
186
|
+
options.onConnectionChange == null ? void 0 : options.onConnectionChange.call(options, 'disconnected');
|
|
187
|
+
}));
|
|
188
|
+
cleanups.push(options.transport.on('sync', (payload)=>{
|
|
189
|
+
applyRemote(payload);
|
|
190
|
+
// The initial sync is sent only after session authorization and room setup.
|
|
191
|
+
// A raw socket connect can precede that setup, so do not flush on connect.
|
|
192
|
+
if (stringValue(payload['updateBase64'])) {
|
|
193
|
+
synchronized = true;
|
|
194
|
+
flush();
|
|
195
|
+
}
|
|
196
|
+
}));
|
|
175
197
|
cleanups.push(options.transport.on('update', applyRemote));
|
|
176
198
|
cleanups.push(options.transport.on('update-ack', (payload)=>{
|
|
177
199
|
const ack = parseAck(payload);
|
|
178
|
-
if (ack
|
|
200
|
+
if (ack && ack.documentId === options.session.documentId) {
|
|
201
|
+
inFlight = [];
|
|
202
|
+
options.onAck == null ? void 0 : options.onAck.call(options, ack);
|
|
203
|
+
flush();
|
|
204
|
+
}
|
|
179
205
|
}));
|
|
180
206
|
cleanups.push(options.transport.on('presence', (payload)=>{
|
|
181
207
|
const item = parsePresence(payload);
|
|
@@ -111,6 +111,8 @@ function createSocketIoTransportAdapter(socket) {
|
|
|
111
111
|
var _options_initialPresence;
|
|
112
112
|
let presence = _extends({}, (_options_initialPresence = options.initialPresence) != null ? _options_initialPresence : {});
|
|
113
113
|
let pending = [];
|
|
114
|
+
let inFlight = [];
|
|
115
|
+
let synchronized = false;
|
|
114
116
|
let flushTimer;
|
|
115
117
|
let syncTimer;
|
|
116
118
|
let presenceTimer;
|
|
@@ -126,9 +128,12 @@ function createSocketIoTransportAdapter(socket) {
|
|
|
126
128
|
const flush = ()=>{
|
|
127
129
|
if (flushTimer) clearTimeout(flushTimer);
|
|
128
130
|
flushTimer = undefined;
|
|
129
|
-
if (!pending.length || !options.transport.connected) return;
|
|
131
|
+
if (!pending.length || inFlight.length || !synchronized || !options.transport.connected) return;
|
|
130
132
|
const updates = pending;
|
|
131
133
|
pending = [];
|
|
134
|
+
// Keep bytes until the server acknowledges persistence. Replaying a Yjs update
|
|
135
|
+
// after a lost acknowledgement is idempotent; dropping it could lose an edit.
|
|
136
|
+
inFlight = updates;
|
|
132
137
|
options.transport.emit('update', {
|
|
133
138
|
updateBase64: bytesToBase64(options.document.mergeUpdates(updates)),
|
|
134
139
|
origin: 'plugin-client'
|
|
@@ -157,23 +162,44 @@ function createSocketIoTransportAdapter(socket) {
|
|
|
157
162
|
started = true;
|
|
158
163
|
options.onConnectionChange == null ? void 0 : options.onConnectionChange.call(options, 'connecting');
|
|
159
164
|
cleanups.push(options.document.onUpdate((update, origin)=>{
|
|
160
|
-
if (origin === remoteOrigin) return;
|
|
165
|
+
if (origin === remoteOrigin || options.session.access !== 'write') return;
|
|
161
166
|
pending.push(update);
|
|
162
167
|
if (!flushTimer) flushTimer = setTimeout(flush, batchMs);
|
|
163
168
|
}));
|
|
164
169
|
cleanups.push(options.transport.on('connect', ()=>{
|
|
170
|
+
synchronized = false;
|
|
165
171
|
var _options_transport_clientId;
|
|
166
172
|
selfClientId = (_options_transport_clientId = options.transport.clientId) != null ? _options_transport_clientId : selfClientId;
|
|
167
173
|
options.onConnectionChange == null ? void 0 : options.onConnectionChange.call(options, 'connected');
|
|
168
174
|
requestSync();
|
|
169
175
|
emitPresence();
|
|
170
176
|
}));
|
|
171
|
-
cleanups.push(options.transport.on('disconnect', ()=>
|
|
172
|
-
|
|
177
|
+
cleanups.push(options.transport.on('disconnect', ()=>{
|
|
178
|
+
synchronized = false;
|
|
179
|
+
pending = [
|
|
180
|
+
...inFlight,
|
|
181
|
+
...pending
|
|
182
|
+
];
|
|
183
|
+
inFlight = [];
|
|
184
|
+
options.onConnectionChange == null ? void 0 : options.onConnectionChange.call(options, 'disconnected');
|
|
185
|
+
}));
|
|
186
|
+
cleanups.push(options.transport.on('sync', (payload)=>{
|
|
187
|
+
applyRemote(payload);
|
|
188
|
+
// The initial sync is sent only after session authorization and room setup.
|
|
189
|
+
// A raw socket connect can precede that setup, so do not flush on connect.
|
|
190
|
+
if (stringValue(payload['updateBase64'])) {
|
|
191
|
+
synchronized = true;
|
|
192
|
+
flush();
|
|
193
|
+
}
|
|
194
|
+
}));
|
|
173
195
|
cleanups.push(options.transport.on('update', applyRemote));
|
|
174
196
|
cleanups.push(options.transport.on('update-ack', (payload)=>{
|
|
175
197
|
const ack = parseAck(payload);
|
|
176
|
-
if (ack
|
|
198
|
+
if (ack && ack.documentId === options.session.documentId) {
|
|
199
|
+
inFlight = [];
|
|
200
|
+
options.onAck == null ? void 0 : options.onAck.call(options, ack);
|
|
201
|
+
flush();
|
|
202
|
+
}
|
|
177
203
|
}));
|
|
178
204
|
cleanups.push(options.transport.on('presence', (payload)=>{
|
|
179
205
|
const item = parsePresence(payload);
|
package/index.cjs.js
CHANGED
|
@@ -39,8 +39,8 @@ var jsTiktoken = require('js-tiktoken');
|
|
|
39
39
|
var zod = require('zod');
|
|
40
40
|
var results = require('./results.cjs.js');
|
|
41
41
|
var connector = require('./connector.cjs.js');
|
|
42
|
-
var collaborationClient = require('./collaboration-client.cjs.js');
|
|
43
42
|
var _object_without_properties_loose$2 = require('./_object_without_properties_loose.cjs.js');
|
|
43
|
+
var collaborationClient = require('./collaboration-client.cjs.js');
|
|
44
44
|
var tools = require('@langchain/core/tools');
|
|
45
45
|
|
|
46
46
|
function _interopNamespaceDefault(e) {
|
|
@@ -4574,6 +4574,107 @@ function taskWaitReason(states, mode) {
|
|
|
4574
4574
|
const AgentExecutionRunnerCapability = modelProvider.createRuntimeCapability('platform.agent_execution.runner');
|
|
4575
4575
|
const AgentExecutionRunnerFactoryCapability = modelProvider.createRuntimeCapability('platform.agent_execution.runner.factory');
|
|
4576
4576
|
|
|
4577
|
+
// Invariants: this payload has no runtime imports; protocol streams are not exit evidence.
|
|
4578
|
+
// The device supervisor regression test enforces identical process supervision semantics.
|
|
4579
|
+
const AGENT_PROCESS_SUPERVISOR = String.raw`
|
|
4580
|
+
import ctypes, errno, json, os, signal, subprocess, sys, time
|
|
4581
|
+
owner = int(sys.argv[1])
|
|
4582
|
+
stopping = False
|
|
4583
|
+
strong = False
|
|
4584
|
+
if sys.platform.startswith('linux'):
|
|
4585
|
+
strong = ctypes.CDLL(None, use_errno=True).prctl(36, 1, 0, 0, 0) == 0
|
|
4586
|
+
def stop(*args):
|
|
4587
|
+
global stopping
|
|
4588
|
+
stopping = True
|
|
4589
|
+
signal.signal(signal.SIGTERM, stop)
|
|
4590
|
+
signal.signal(signal.SIGINT, stop)
|
|
4591
|
+
# The supervisor is the process-group leader. Its live PID reserves the group identity.
|
|
4592
|
+
os.write(3, b'{"ready":true}\n')
|
|
4593
|
+
try:
|
|
4594
|
+
if os.getppid() != owner: raise OSError('Original host exited before admission')
|
|
4595
|
+
child = subprocess.Popen(sys.argv[2:], close_fds=True)
|
|
4596
|
+
except OSError:
|
|
4597
|
+
os.write(3, json.dumps({'version': 1, 'state': 'not_started', 'coverage': 'descendants', 'exitCode': 127}).encode())
|
|
4598
|
+
sys.exit(0)
|
|
4599
|
+
# Only the protocol child owns stdin, so a closed transport still produces EPIPE.
|
|
4600
|
+
os.close(0)
|
|
4601
|
+
code = None
|
|
4602
|
+
deadline = None
|
|
4603
|
+
while True:
|
|
4604
|
+
if os.getppid() != owner: stopping = True
|
|
4605
|
+
if code is None:
|
|
4606
|
+
value = child.poll()
|
|
4607
|
+
if value is not None: code = value; stopping = True
|
|
4608
|
+
if stopping and deadline is None:
|
|
4609
|
+
deadline = time.monotonic() + 2
|
|
4610
|
+
os.killpg(os.getpgrp(), signal.SIGTERM)
|
|
4611
|
+
if deadline is not None and time.monotonic() >= deadline:
|
|
4612
|
+
if not strong:
|
|
4613
|
+
# No subreaper means escaped descendants cannot be certified. No receipt is emitted.
|
|
4614
|
+
os.killpg(os.getpgrp(), signal.SIGKILL)
|
|
4615
|
+
# Kill only still-waitable direct children. Orphans are adopted by this subreaper;
|
|
4616
|
+
# holding them until waitpid prevents PID reuse between selection and signalling.
|
|
4617
|
+
try:
|
|
4618
|
+
ids = open('/proc/self/task/' + str(os.getpid()) + '/children').read().split()
|
|
4619
|
+
for value in ids:
|
|
4620
|
+
try: os.kill(int(value), signal.SIGKILL)
|
|
4621
|
+
except ProcessLookupError: pass
|
|
4622
|
+
except OSError:
|
|
4623
|
+
os.killpg(os.getpgrp(), signal.SIGKILL)
|
|
4624
|
+
if stopping and strong:
|
|
4625
|
+
empty = False
|
|
4626
|
+
while True:
|
|
4627
|
+
try:
|
|
4628
|
+
pid, status = os.waitpid(-1, os.WNOHANG)
|
|
4629
|
+
if pid == 0: break
|
|
4630
|
+
if pid == child.pid and code is None: code = os.waitstatus_to_exitcode(status)
|
|
4631
|
+
except ChildProcessError:
|
|
4632
|
+
empty = True
|
|
4633
|
+
break
|
|
4634
|
+
if empty:
|
|
4635
|
+
os.write(3, json.dumps({'version': 1, 'state': 'exited', 'coverage': 'descendants', 'exitCode': code}).encode())
|
|
4636
|
+
sys.exit(0)
|
|
4637
|
+
time.sleep(.02)
|
|
4638
|
+
`;
|
|
4639
|
+
|
|
4640
|
+
/** Persisted host ownership marker. Only built-in presets are supported. */ const managedAgentRuntimeSchema = v3.z.object({
|
|
4641
|
+
type: v3.z.literal('builtin'),
|
|
4642
|
+
version: v3.z.string().min(1)
|
|
4643
|
+
}).strict();
|
|
4644
|
+
/** Launch settings supplied by the installed strategy, never by tool input or host provider lists. */ const agentRuntimeDeploymentSpecSchema = v3.z.discriminatedUnion('type', [
|
|
4645
|
+
v3.z.object({
|
|
4646
|
+
type: v3.z.literal('process'),
|
|
4647
|
+
command: v3.z.string().min(1).refine((value)=>!value.includes('\0')),
|
|
4648
|
+
args: v3.z.array(v3.z.string().refine((value)=>!value.includes('\0'))),
|
|
4649
|
+
environment: v3.z.record(v3.z.string(), v3.z.string()),
|
|
4650
|
+
model: v3.z.string().min(1).optional(),
|
|
4651
|
+
timeoutMs: v3.z.number().int().min(1000).max(3600000)
|
|
4652
|
+
}).strict(),
|
|
4653
|
+
v3.z.object({
|
|
4654
|
+
type: v3.z.literal('sdk'),
|
|
4655
|
+
environment: v3.z.record(v3.z.string(), v3.z.string()),
|
|
4656
|
+
model: v3.z.string().min(1).optional(),
|
|
4657
|
+
timeoutMs: v3.z.number().int().min(1000).max(3600000)
|
|
4658
|
+
}).strict(),
|
|
4659
|
+
v3.z.object({
|
|
4660
|
+
type: v3.z.literal('service'),
|
|
4661
|
+
serverUrl: v3.z.string().url().refine((value)=>{
|
|
4662
|
+
try {
|
|
4663
|
+
const url = new URL(value);
|
|
4664
|
+
return [
|
|
4665
|
+
'http:',
|
|
4666
|
+
'https:'
|
|
4667
|
+
].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
|
|
4668
|
+
} catch (e) {
|
|
4669
|
+
return false;
|
|
4670
|
+
}
|
|
4671
|
+
}),
|
|
4672
|
+
authorization: v3.z.string().optional(),
|
|
4673
|
+
timeoutMs: v3.z.number().int().min(1000).max(3600000)
|
|
4674
|
+
}).strict()
|
|
4675
|
+
]);
|
|
4676
|
+
/** Used by SDK/process/service adapters. The host pins the target and rechecks access; no caller-selected scope. */ const AgentRuntimeDeploymentCapability = modelProvider.createRuntimeCapability('platform.agent_runtime.deployment');
|
|
4677
|
+
|
|
4577
4678
|
/** Host-only provenance. This describes a saved operation; it never grants access by itself. */ const projectPipelineInvocationScopeSchema = v3.z.object({
|
|
4578
4679
|
tenantId: v3.z.string().uuid(),
|
|
4579
4680
|
organizationId: v3.z.string().uuid(),
|
|
@@ -4593,6 +4694,69 @@ const AgentExecutionRunnerFactoryCapability = modelProvider.createRuntimeCapabil
|
|
|
4593
4694
|
|
|
4594
4695
|
/** Older runtime plugins can still send this event; new emissions use ON_CHAT_EVENT. */ const RESOURCE_CARD_EVENT = 'xpert.resource_card';
|
|
4595
4696
|
|
|
4697
|
+
function middleware(node) {
|
|
4698
|
+
return node.type === 'workflow' && node.entity.type === contracts.WorkflowNodeTypeEnum.MIDDLEWARE;
|
|
4699
|
+
}
|
|
4700
|
+
function hasAssistantMiddleware(draft, provider) {
|
|
4701
|
+
return draft.nodes.some((node)=>middleware(node) && node.entity.provider === provider && draft.connections.some((edge)=>{
|
|
4702
|
+
var _draft_team_agent;
|
|
4703
|
+
return edge.type === 'workflow' && edge.from === ((_draft_team_agent = draft.team.agent) == null ? void 0 : _draft_team_agent.key) && edge.to.split('/')[0] === node.key;
|
|
4704
|
+
}));
|
|
4705
|
+
}
|
|
4706
|
+
/** Compose only the draft graph. The platform records the contribution for safe removal.
|
|
4707
|
+
* No Project, permission, external resource or implicit replacement is created here. */ function applyAssistantMiddleware(draft, input) {
|
|
4708
|
+
var _agent_entity_prompt;
|
|
4709
|
+
const agent = draft.nodes.find((node)=>{
|
|
4710
|
+
var _draft_team_agent;
|
|
4711
|
+
return node.type === 'agent' && node.key === ((_draft_team_agent = draft.team.agent) == null ? void 0 : _draft_team_agent.key);
|
|
4712
|
+
});
|
|
4713
|
+
if ((agent == null ? void 0 : agent.type) !== 'agent') throw new common.BadRequestException('assistant.invalid_draft');
|
|
4714
|
+
if (!hasAssistantMiddleware(draft, input.provider)) {
|
|
4715
|
+
var _agent_entity_options, _agent_entity_options_middlewares, _agent_entity_options1;
|
|
4716
|
+
let key = input.key;
|
|
4717
|
+
for(let suffix = 2; draft.nodes.some((node)=>node.key === key) || draft.connections.some((edge)=>edge.key === `${agent.key}/${key}`); suffix++)key = `${input.key}_${suffix}`;
|
|
4718
|
+
const entity = {
|
|
4719
|
+
id: key,
|
|
4720
|
+
key,
|
|
4721
|
+
type: contracts.WorkflowNodeTypeEnum.MIDDLEWARE,
|
|
4722
|
+
title: input.title,
|
|
4723
|
+
provider: input.provider,
|
|
4724
|
+
required: true,
|
|
4725
|
+
options: {}
|
|
4726
|
+
};
|
|
4727
|
+
draft.nodes.push({
|
|
4728
|
+
type: 'workflow',
|
|
4729
|
+
key,
|
|
4730
|
+
position: {
|
|
4731
|
+
x: 620,
|
|
4732
|
+
y: 160 * (draft.nodes.length - 1)
|
|
4733
|
+
},
|
|
4734
|
+
entity
|
|
4735
|
+
});
|
|
4736
|
+
draft.connections.push({
|
|
4737
|
+
key: `${agent.key}/${key}`,
|
|
4738
|
+
type: 'workflow',
|
|
4739
|
+
from: agent.key,
|
|
4740
|
+
to: key,
|
|
4741
|
+
required: true
|
|
4742
|
+
});
|
|
4743
|
+
var _agent_entity_options_middlewares_order;
|
|
4744
|
+
agent.entity.options = _extends._extends({}, agent.entity.options, {
|
|
4745
|
+
parallelToolCalls: false,
|
|
4746
|
+
middlewares: _extends._extends({}, (_agent_entity_options = agent.entity.options) == null ? void 0 : _agent_entity_options.middlewares, {
|
|
4747
|
+
order: [
|
|
4748
|
+
...(_agent_entity_options_middlewares_order = (_agent_entity_options1 = agent.entity.options) == null ? void 0 : (_agent_entity_options_middlewares = _agent_entity_options1.middlewares) == null ? void 0 : _agent_entity_options_middlewares.order) != null ? _agent_entity_options_middlewares_order : [],
|
|
4749
|
+
key
|
|
4750
|
+
]
|
|
4751
|
+
})
|
|
4752
|
+
});
|
|
4753
|
+
}
|
|
4754
|
+
if (!((_agent_entity_prompt = agent.entity.prompt) == null ? void 0 : _agent_entity_prompt.includes(input.instructions))) agent.entity.prompt = [
|
|
4755
|
+
agent.entity.prompt,
|
|
4756
|
+
input.instructions
|
|
4757
|
+
].filter(Boolean).join('\n\n');
|
|
4758
|
+
}
|
|
4759
|
+
|
|
4596
4760
|
const ASSISTANT_CAPABILITY_PROVIDER = 'ASSISTANT_CAPABILITY_PROVIDER';
|
|
4597
4761
|
const AssistantCapabilityProvider = (key)=>common.applyDecorators(common.SetMetadata(ASSISTANT_CAPABILITY_PROVIDER, key), common.SetMetadata(STRATEGY_META_KEY, ASSISTANT_CAPABILITY_PROVIDER));
|
|
4598
4762
|
exports.AssistantCapabilityProviderRegistry = class AssistantCapabilityProviderRegistry extends BaseStrategyRegistry {
|
|
@@ -4959,26 +5123,59 @@ function resolveSandboxBackend(sandbox) {
|
|
|
4959
5123
|
return isSandboxBackend(candidate) ? candidate : null;
|
|
4960
5124
|
}
|
|
4961
5125
|
|
|
5126
|
+
const editMetricsSchema = v3.z.object({
|
|
5127
|
+
occurrences: v3.z.number().int().nonnegative(),
|
|
5128
|
+
oldLines: v3.z.number().int().nonnegative(),
|
|
5129
|
+
newLines: v3.z.number().int().nonnegative(),
|
|
5130
|
+
changed: v3.z.boolean(),
|
|
5131
|
+
diff: v3.z.object({
|
|
5132
|
+
removed: v3.z.number().int().nonnegative(),
|
|
5133
|
+
added: v3.z.number().int().nonnegative()
|
|
5134
|
+
}).optional(),
|
|
5135
|
+
diffUnavailable: v3.z.enum([
|
|
5136
|
+
'comparison_budget_exceeded',
|
|
5137
|
+
'diff_unavailable'
|
|
5138
|
+
]).optional()
|
|
5139
|
+
});
|
|
5140
|
+
function editMetrics(output) {
|
|
5141
|
+
try {
|
|
5142
|
+
const result = editMetricsSchema.safeParse(JSON.parse(output));
|
|
5143
|
+
if (!result.success) return undefined;
|
|
5144
|
+
const _result_data = result.data, { diff } = _result_data, metrics = _object_without_properties_loose$2._object_without_properties_loose(_result_data, [
|
|
5145
|
+
"diff"
|
|
5146
|
+
]);
|
|
5147
|
+
return _extends._extends({}, metrics, diff ? {
|
|
5148
|
+
diff: {
|
|
5149
|
+
removed: diff.removed,
|
|
5150
|
+
added: diff.added
|
|
5151
|
+
}
|
|
5152
|
+
} : {});
|
|
5153
|
+
} catch (e) {
|
|
5154
|
+
return undefined;
|
|
5155
|
+
}
|
|
5156
|
+
}
|
|
4962
5157
|
function editCommandResult(filePath, result) {
|
|
5158
|
+
const metrics = editMetrics(result.output);
|
|
4963
5159
|
switch(result.exitCode){
|
|
4964
5160
|
case 0:
|
|
4965
|
-
return {
|
|
5161
|
+
return _extends._extends({
|
|
4966
5162
|
path: filePath,
|
|
4967
|
-
filesUpdate: null
|
|
5163
|
+
filesUpdate: null
|
|
5164
|
+
}, metrics != null ? metrics : {
|
|
4968
5165
|
occurrences: parseInt(result.output.trim(), 10) || 1
|
|
4969
|
-
};
|
|
5166
|
+
});
|
|
4970
5167
|
case 1:
|
|
4971
|
-
return {
|
|
5168
|
+
return _extends._extends({}, metrics, {
|
|
4972
5169
|
error: `String not found in file '${filePath}'`
|
|
4973
|
-
};
|
|
5170
|
+
});
|
|
4974
5171
|
case 2:
|
|
4975
|
-
return {
|
|
5172
|
+
return _extends._extends({}, metrics, {
|
|
4976
5173
|
error: `Multiple occurrences found in '${filePath}'. Use replaceAll=true to replace all.`
|
|
4977
|
-
};
|
|
5174
|
+
});
|
|
4978
5175
|
case 3:
|
|
4979
|
-
return {
|
|
5176
|
+
return _extends._extends({}, metrics, {
|
|
4980
5177
|
error: `Error: File '${filePath}' not found`
|
|
4981
|
-
};
|
|
5178
|
+
});
|
|
4982
5179
|
default:
|
|
4983
5180
|
return {
|
|
4984
5181
|
error: `Unknown error editing file '${filePath}'`
|
|
@@ -5020,6 +5217,88 @@ function editCommandResult(filePath, result) {
|
|
|
5020
5217
|
};
|
|
5021
5218
|
}
|
|
5022
5219
|
|
|
5220
|
+
// Embedded in the existing sandbox Node process; no Git, subprocess, or temporary files.
|
|
5221
|
+
const FILE_EDIT_DIFF_SCRIPT = String.raw`
|
|
5222
|
+
function inspectLineDiff(before, after) {
|
|
5223
|
+
if (before === after) return { diff: { removed: 0, added: 0 } };
|
|
5224
|
+
// Include line terminators so a missing final newline is an actual line change.
|
|
5225
|
+
const oldLines = before.match(/[^\n]*\n|[^\n]+$/g) || [];
|
|
5226
|
+
const newLines = after.match(/[^\n]*\n|[^\n]+$/g) || [];
|
|
5227
|
+
let start = 0, oldEnd = oldLines.length, newEnd = newLines.length;
|
|
5228
|
+
while (start < oldEnd && start < newEnd && oldLines[start] === newLines[start]) start++;
|
|
5229
|
+
while (oldEnd > start && newEnd > start && oldLines[oldEnd - 1] === newLines[newEnd - 1]) {
|
|
5230
|
+
oldEnd--;
|
|
5231
|
+
newEnd--;
|
|
5232
|
+
}
|
|
5233
|
+
const removed = oldEnd - start, added = newEnd - start;
|
|
5234
|
+
if (!removed || !added) return { diff: { removed, added } };
|
|
5235
|
+
|
|
5236
|
+
// Myers shortest edit distance needs only a frontier when reporting counts, not a patch.
|
|
5237
|
+
// Bound the optional quadratic search on broad rewrites; never limit the edit itself.
|
|
5238
|
+
const maxDistance = Math.min(removed + added, 2000);
|
|
5239
|
+
const offset = maxDistance + 1;
|
|
5240
|
+
const frontier = new Int32Array(2 * maxDistance + 3);
|
|
5241
|
+
let work = 0;
|
|
5242
|
+
for (let distance = 0; distance <= maxDistance; distance++) {
|
|
5243
|
+
for (let diagonal = -distance; diagonal <= distance; diagonal += 2) {
|
|
5244
|
+
if (++work > 1000000) return { diffUnavailable: 'comparison_budget_exceeded' };
|
|
5245
|
+
const index = offset + diagonal;
|
|
5246
|
+
let x = diagonal === -distance || (diagonal !== distance && frontier[index - 1] < frontier[index + 1])
|
|
5247
|
+
? frontier[index + 1]
|
|
5248
|
+
: frontier[index - 1] + 1;
|
|
5249
|
+
let y = x - diagonal;
|
|
5250
|
+
while (x < removed && y < added && oldLines[start + x] === newLines[start + y]) {
|
|
5251
|
+
if (++work > 1000000) return { diffUnavailable: 'comparison_budget_exceeded' };
|
|
5252
|
+
x++;
|
|
5253
|
+
y++;
|
|
5254
|
+
}
|
|
5255
|
+
if (x >= removed && y >= added) {
|
|
5256
|
+
return { diff: { removed: (distance + removed - added) / 2, added: (distance + added - removed) / 2 } };
|
|
5257
|
+
}
|
|
5258
|
+
frontier[index] = x;
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5261
|
+
return { diffUnavailable: 'comparison_budget_exceeded' };
|
|
5262
|
+
}
|
|
5263
|
+
`;
|
|
5264
|
+
|
|
5265
|
+
/** Compare actual file contents inside the sandbox; reporting must never prevent an edit. */ function buildEditCommand(filePath, oldString, newString, replaceAll) {
|
|
5266
|
+
const encoded = Buffer.from(JSON.stringify({
|
|
5267
|
+
filePath,
|
|
5268
|
+
oldString,
|
|
5269
|
+
newString,
|
|
5270
|
+
replaceAll
|
|
5271
|
+
})).toString('base64');
|
|
5272
|
+
const script = `
|
|
5273
|
+
const fs = require('node:fs');
|
|
5274
|
+
const input = JSON.parse(Buffer.from('${encoded}', 'base64').toString('utf8'));
|
|
5275
|
+
const lines = text => text.length ? text.split('\\n').length - Number(text.endsWith('\\n')) : 0;
|
|
5276
|
+
const metrics = { oldLines: lines(input.oldString), newLines: lines(input.newString) };
|
|
5277
|
+
|
|
5278
|
+
${FILE_EDIT_DIFF_SCRIPT}
|
|
5279
|
+
|
|
5280
|
+
function unchanged(exitCode) {
|
|
5281
|
+
console.log(JSON.stringify({ ...metrics, occurrences: 0, changed: false, diff: { removed: 0, added: 0 } }));
|
|
5282
|
+
process.exit(exitCode);
|
|
5283
|
+
}
|
|
5284
|
+
let before;
|
|
5285
|
+
try { before = fs.readFileSync(input.filePath, 'utf8'); } catch { unchanged(3); }
|
|
5286
|
+
const occurrences = before.split(input.oldString).length - 1;
|
|
5287
|
+
if (occurrences === 0) unchanged(1);
|
|
5288
|
+
if (occurrences > 1 && !input.replaceAll) unchanged(2);
|
|
5289
|
+
const after = before.split(input.oldString).join(input.newString);
|
|
5290
|
+
const changed = before !== after;
|
|
5291
|
+
if (changed) fs.writeFileSync(input.filePath, after, 'utf8');
|
|
5292
|
+
try {
|
|
5293
|
+
Object.assign(metrics, inspectLineDiff(before, after));
|
|
5294
|
+
} catch {
|
|
5295
|
+
metrics.diffUnavailable = 'diff_unavailable';
|
|
5296
|
+
}
|
|
5297
|
+
console.log(JSON.stringify({ ...metrics, occurrences, changed }));
|
|
5298
|
+
`;
|
|
5299
|
+
return `node -e '${script.replace(/'/g, "'\\''")}'`;
|
|
5300
|
+
}
|
|
5301
|
+
|
|
5023
5302
|
const MAX_LINE_LENGTH = 500;
|
|
5024
5303
|
const MAX_GREP_LINE_LENGTH = 2000;
|
|
5025
5304
|
const GREP_RESULT_LIMIT = 100;
|
|
@@ -5519,41 +5798,6 @@ fs.appendFileSync(filePath, content, 'utf-8');
|
|
|
5519
5798
|
console.log('OK');
|
|
5520
5799
|
"`;
|
|
5521
5800
|
}
|
|
5522
|
-
/**
|
|
5523
|
-
* Node.js command template for editing files.
|
|
5524
|
-
*/ function buildEditCommand(filePath, oldStr, newStr, replaceAll) {
|
|
5525
|
-
const pathB64 = utf8ToBase64(filePath);
|
|
5526
|
-
const oldB64 = utf8ToBase64(oldStr);
|
|
5527
|
-
const newB64 = utf8ToBase64(newStr);
|
|
5528
|
-
return `node -e "
|
|
5529
|
-
const fs = require('fs');
|
|
5530
|
-
|
|
5531
|
-
const filePath = Buffer.from('${pathB64}', 'base64').toString('utf-8');
|
|
5532
|
-
const oldStr = Buffer.from('${oldB64}', 'base64').toString('utf-8');
|
|
5533
|
-
const newStr = Buffer.from('${newB64}', 'base64').toString('utf-8');
|
|
5534
|
-
const replaceAll = ${Boolean(replaceAll)};
|
|
5535
|
-
|
|
5536
|
-
let text;
|
|
5537
|
-
try {
|
|
5538
|
-
text = fs.readFileSync(filePath, 'utf-8');
|
|
5539
|
-
} catch (e) {
|
|
5540
|
-
process.exit(3);
|
|
5541
|
-
}
|
|
5542
|
-
|
|
5543
|
-
const count = text.split(oldStr).length - 1;
|
|
5544
|
-
|
|
5545
|
-
if (count === 0) {
|
|
5546
|
-
process.exit(1);
|
|
5547
|
-
}
|
|
5548
|
-
if (count > 1 && !replaceAll) {
|
|
5549
|
-
process.exit(2);
|
|
5550
|
-
}
|
|
5551
|
-
|
|
5552
|
-
const result = text.split(oldStr).join(newStr);
|
|
5553
|
-
fs.writeFileSync(filePath, result, 'utf-8');
|
|
5554
|
-
console.log(count);
|
|
5555
|
-
"`;
|
|
5556
|
-
}
|
|
5557
5801
|
/**
|
|
5558
5802
|
* Node.js command template for grep operations.
|
|
5559
5803
|
*/ function buildGrepCommand(pattern, searchPath, globPattern) {
|
|
@@ -6013,6 +6257,8 @@ function normalizePluginJobProcessorMetadata(options) {
|
|
|
6013
6257
|
pluginName,
|
|
6014
6258
|
queueName,
|
|
6015
6259
|
jobName
|
|
6260
|
+
}, options.controlContract === undefined ? {} : {
|
|
6261
|
+
controlContract: requireManagedQueueDecoratorValue(options.controlContract, 'controlContract')
|
|
6016
6262
|
}, concurrency === undefined ? {} : {
|
|
6017
6263
|
concurrency: Math.trunc(concurrency)
|
|
6018
6264
|
});
|
|
@@ -6585,9 +6831,19 @@ const ContentReferencesRuntimeCapability = modelProvider.createRuntimeCapability
|
|
|
6585
6831
|
description: 'Authorized durable document references; plugins provide source-specific listing and files.'
|
|
6586
6832
|
});
|
|
6587
6833
|
|
|
6834
|
+
/** Matching semantic type alone never grants a writer access to an incompatible native model. */ function supportsContentModel(editor, model, access) {
|
|
6835
|
+
return editor.supports.some((item)=>item.typeId === model.typeId && item.modelId === model.modelId && item.schemaVersion === model.schemaVersion && item.editProtocol.id === model.editProtocol.id && item.editProtocol.version === model.editProtocol.version && item.access.includes(access));
|
|
6836
|
+
}
|
|
6837
|
+
|
|
6588
6838
|
function isTextContentEditor(provider) {
|
|
6589
6839
|
return provider.descriptor.kind === 'text-document';
|
|
6590
6840
|
}
|
|
6841
|
+
function isFileContentEditor(provider) {
|
|
6842
|
+
return provider.descriptor.kind === 'file';
|
|
6843
|
+
}
|
|
6844
|
+
function isResourceContentEditor(provider) {
|
|
6845
|
+
return provider.descriptor.kind === 'resource';
|
|
6846
|
+
}
|
|
6591
6847
|
const EDITOR_PROVIDER = 'XPERT_CONTENT_EDITOR_PROVIDER';
|
|
6592
6848
|
const ContentEditorProvider = (key)=>common.applyDecorators(common.SetMetadata(EDITOR_PROVIDER, key), common.SetMetadata(STRATEGY_META_KEY, EDITOR_PROVIDER));
|
|
6593
6849
|
exports.ContentEditorRegistry = class ContentEditorRegistry extends BaseStrategyRegistry {
|
|
@@ -10955,6 +11211,7 @@ exports.ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN = ACCOUNT_BINDING_PERMISSION_SE
|
|
|
10955
11211
|
exports.AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING;
|
|
10956
11212
|
exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
|
|
10957
11213
|
exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
|
|
11214
|
+
exports.AGENT_PROCESS_SUPERVISOR = AGENT_PROCESS_SUPERVISOR;
|
|
10958
11215
|
exports.AGENT_RUNTIME_EVENT_MESSAGE_TYPE = AGENT_RUNTIME_EVENT_MESSAGE_TYPE;
|
|
10959
11216
|
exports.AGENT_RUNTIME_STRATEGY = AGENT_RUNTIME_STRATEGY;
|
|
10960
11217
|
exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
|
|
@@ -10968,6 +11225,7 @@ exports.AgentExecutionRunnerCapability = AgentExecutionRunnerCapability;
|
|
|
10968
11225
|
exports.AgentExecutionRunnerFactoryCapability = AgentExecutionRunnerFactoryCapability;
|
|
10969
11226
|
exports.AgentInvocationRuntimeCapability = AgentInvocationRuntimeCapability;
|
|
10970
11227
|
exports.AgentMiddlewareStrategy = AgentMiddlewareStrategy;
|
|
11228
|
+
exports.AgentRuntimeDeploymentCapability = AgentRuntimeDeploymentCapability;
|
|
10971
11229
|
exports.AgentRuntimeFactoryCapability = AgentRuntimeFactoryCapability;
|
|
10972
11230
|
exports.AgentRuntimeStrategy = AgentRuntimeStrategy;
|
|
10973
11231
|
exports.AiModelNotFoundException = AiModelNotFoundException;
|
|
@@ -11179,6 +11437,7 @@ exports.XpertToolProvider = XpertToolProvider;
|
|
|
11179
11437
|
exports.agentInvocationDispatchContextSchema = agentInvocationDispatchContextSchema;
|
|
11180
11438
|
exports.agentRuntimeConsumptionStateSchema = agentRuntimeConsumptionStateSchema;
|
|
11181
11439
|
exports.agentRuntimeDeliveryStateSchema = agentRuntimeDeliveryStateSchema;
|
|
11440
|
+
exports.agentRuntimeDeploymentSpecSchema = agentRuntimeDeploymentSpecSchema;
|
|
11182
11441
|
exports.agentRuntimeEventMessageId = agentRuntimeEventMessageId;
|
|
11183
11442
|
exports.agentRuntimeEventSchema = agentRuntimeEventSchema;
|
|
11184
11443
|
exports.agentRuntimeReplyTargetSchema = agentRuntimeReplyTargetSchema;
|
|
@@ -11186,6 +11445,7 @@ exports.agentRuntimeResultClaimSchema = agentRuntimeResultClaimSchema;
|
|
|
11186
11445
|
exports.agentRuntimeResultConsumptionKey = agentRuntimeResultConsumptionKey;
|
|
11187
11446
|
exports.als = als;
|
|
11188
11447
|
exports.appendSandboxMessage = appendSandboxMessage;
|
|
11448
|
+
exports.applyAssistantMiddleware = applyAssistantMiddleware;
|
|
11189
11449
|
exports.applyModelConfiguration = applyModelConfiguration;
|
|
11190
11450
|
exports.applyModelContextSize = applyModelContextSize;
|
|
11191
11451
|
exports.artifactPresentationKey = artifactPresentationKey;
|
|
@@ -11224,12 +11484,15 @@ exports.getRequestContext = getRequestContext;
|
|
|
11224
11484
|
exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
|
|
11225
11485
|
exports.getTenantGlobalScopeKey = getTenantGlobalScopeKey;
|
|
11226
11486
|
exports.getXpertToolMethod = getXpertToolMethod;
|
|
11487
|
+
exports.hasAssistantMiddleware = hasAssistantMiddleware;
|
|
11227
11488
|
exports.isAgentInvocationTerminal = isAgentInvocationTerminal;
|
|
11228
11489
|
exports.isDevelopmentSandboxRuntimeEnvironment = isDevelopmentSandboxRuntimeEnvironment;
|
|
11490
|
+
exports.isFileContentEditor = isFileContentEditor;
|
|
11229
11491
|
exports.isModelOutputValidationError = isModelOutputValidationError;
|
|
11230
11492
|
exports.isModelUsagePricingConfig = isModelUsagePricingConfig;
|
|
11231
11493
|
exports.isPluginArtifactNamespace = isPluginArtifactNamespace;
|
|
11232
11494
|
exports.isRemoteFile = isRemoteFile;
|
|
11495
|
+
exports.isResourceContentEditor = isResourceContentEditor;
|
|
11233
11496
|
exports.isSandboxBackend = isSandboxBackend;
|
|
11234
11497
|
exports.isSandboxManagedServiceAdapter = isSandboxManagedServiceAdapter;
|
|
11235
11498
|
exports.isSandboxServiceProxyAdapter = isSandboxServiceProxyAdapter;
|
|
@@ -11241,6 +11504,7 @@ exports.isTextContentEditor = isTextContentEditor;
|
|
|
11241
11504
|
exports.jsonEncodedSchema = jsonEncodedSchema;
|
|
11242
11505
|
exports.knowledgebaseActions = knowledgebaseActions;
|
|
11243
11506
|
exports.loadYamlFile = loadYamlFile;
|
|
11507
|
+
exports.managedAgentRuntimeSchema = managedAgentRuntimeSchema;
|
|
11244
11508
|
exports.mergeCredentials = mergeCredentials;
|
|
11245
11509
|
exports.mergeModelRequirements = mergeModelRequirements;
|
|
11246
11510
|
exports.mergeParentChildChunks = mergeParentChildChunks;
|
|
@@ -11270,6 +11534,7 @@ exports.runtimeToolProviderComponent = runtimeToolProviderComponent;
|
|
|
11270
11534
|
exports.secondsToMilliseconds = secondsToMilliseconds;
|
|
11271
11535
|
exports.setDefaultTenantId = setDefaultTenantId;
|
|
11272
11536
|
exports.sumTokenUsage = sumTokenUsage;
|
|
11537
|
+
exports.supportsContentModel = supportsContentModel;
|
|
11273
11538
|
exports.taskWaitReason = taskWaitReason;
|
|
11274
11539
|
exports.textTokenBoundaries = textTokenBoundaries;
|
|
11275
11540
|
exports.validateAnalyticsPayload = validateAnalyticsPayload;
|