@xpert-ai/plugin-sdk 3.27.0 → 3.29.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.
Files changed (60) hide show
  1. package/collaboration-client.cjs.js +31 -5
  2. package/collaboration-client.esm.js +31 -5
  3. package/data-workbench.cjs.js +0 -679
  4. package/data-workbench.esm.js +1 -676
  5. package/docs/artifact-presentations.md +2 -0
  6. package/docs/artifact-types.md +97 -0
  7. package/docs/data-workbench.md +37 -0
  8. package/index.cjs.js +481 -49
  9. package/index.esm.js +469 -49
  10. package/model-provider.cjs.js +7 -1
  11. package/model-provider.esm.js +7 -2
  12. package/package.json +2 -2
  13. package/src/data-workbench.d.ts +0 -2
  14. package/src/index.d.ts +2 -0
  15. package/src/lib/agent/handoff/types.d.ts +5 -0
  16. package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +6 -1
  17. package/src/lib/agent/middleware/capabilities/execution-observability.d.ts +26 -0
  18. package/src/lib/agent/middleware/capabilities/index.d.ts +1 -0
  19. package/src/lib/agent/runtime/capability.d.ts +4 -0
  20. package/src/lib/agent/runtime/cli-model-profile.d.ts +1 -1
  21. package/src/lib/agent/runtime/execution-runner.d.ts +11 -0
  22. package/src/lib/agent/runtime/index.d.ts +2 -0
  23. package/src/lib/agent/runtime/managed.d.ts +94 -0
  24. package/src/lib/agent/runtime/process-supervisor.d.ts +1 -0
  25. package/src/lib/agent/runtime/strategy.d.ts +14 -0
  26. package/src/lib/agent/runtime/types.d.ts +30 -1
  27. package/src/lib/ai-model/native-model.d.ts +5 -1
  28. package/src/lib/artifact-type/definition.schema.d.ts +119 -0
  29. package/src/lib/artifact-type/index.d.ts +91 -0
  30. package/src/lib/artifact-type/registry.d.ts +25 -0
  31. package/src/lib/assistant-capability/index.d.ts +1 -0
  32. package/src/lib/assistant-capability/middleware.d.ts +10 -0
  33. package/src/lib/collaboration/types.d.ts +5 -0
  34. package/src/lib/content-resource/catalog.d.ts +88 -0
  35. package/src/lib/content-resource/editor-compatibility.d.ts +3 -0
  36. package/src/lib/content-resource/editor.d.ts +35 -3
  37. package/src/lib/content-resource/index.d.ts +3 -0
  38. package/src/lib/data/datasource/adapter.strategy.d.ts +3 -0
  39. package/src/lib/data/datasource/index.d.ts +0 -2
  40. package/src/lib/data/datasource/strategy.interface.d.ts +5 -1
  41. package/src/lib/data/datasource/types.d.ts +2 -2
  42. package/src/lib/data/datasource/workbench.d.ts +4 -3
  43. package/src/lib/execution-control/context.d.ts +7 -0
  44. package/src/lib/execution-control/index.d.ts +2 -0
  45. package/src/lib/managed-queue/index.d.ts +12 -0
  46. package/src/lib/runtime/capabilities/artifact-drafts.d.ts +10 -1
  47. package/src/lib/runtime/capabilities/artifact-library.d.ts +52 -0
  48. package/src/lib/runtime/capabilities/artifacts.d.ts +15 -0
  49. package/src/lib/runtime/capabilities/index.d.ts +1 -0
  50. package/src/lib/runtime/capabilities/mcp-client-runtime.d.ts +2 -0
  51. package/src/lib/runtime/capabilities/sandbox-jobs.d.ts +12 -3
  52. package/src/lib/sandbox/file-edit-command.d.ts +2 -0
  53. package/src/lib/sandbox/file-edit-diff.d.ts +1 -0
  54. package/src/lib/sandbox/protocol.d.ts +13 -1
  55. package/src/lib/sandbox/runtime-provider.d.ts +12 -0
  56. package/src/lib/data/datasource/workbench-adapter.d.ts +0 -51
  57. package/src/lib/data/datasource/workbench-pagination.d.ts +0 -6
  58. package/src/lib/data/datasource/workbench-sql-lexer.d.ts +0 -11
  59. package/src/lib/data/datasource/workbench-sql-syntax.d.ts +0 -3
  60. package/src/lib/data/datasource/workbench-sql.d.ts +0 -20
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) {
@@ -4304,6 +4304,14 @@ const FileRuntimeCapability = modelProvider.createRuntimeCapability('platform.fi
4304
4304
  description: 'Resolve platform file handles into previewable file URLs.'
4305
4305
  });
4306
4306
 
4307
+ /** Credential audience check only; the host must still revalidate the human's live admin role and grant. */ function isExecutionObservationSession(principal, xpertId) {
4308
+ var _principal_resourceScope;
4309
+ return !principal || Boolean(xpertId && principal.principalType === 'client_secret' && principal.clientSecretBindingType === contracts.SecretTokenBindingType.USER_XPERT && principal.clientSecretId && ((_principal_resourceScope = principal.resourceScope) == null ? void 0 : _principal_resourceScope.kind) === 'assistant' && principal.resourceScope.xpertId === xpertId);
4310
+ }
4311
+ const ExecutionObservabilityRuntimeCapability = modelProvider.createRuntimeCapability('platform.execution_observability', {
4312
+ description: 'Administrator-only execution analytics within the host-bound tenant and organization.'
4313
+ });
4314
+
4307
4315
  const XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN = 'XPERT_AGENT_MIDDLEWARE_RUNTIME';
4308
4316
 
4309
4317
  const MODEL_OUTPUT_VALIDATION_ERROR_CODE = 'MODEL_OUTPUT_VALIDATION_ERROR';
@@ -4574,6 +4582,107 @@ function taskWaitReason(states, mode) {
4574
4582
  const AgentExecutionRunnerCapability = modelProvider.createRuntimeCapability('platform.agent_execution.runner');
4575
4583
  const AgentExecutionRunnerFactoryCapability = modelProvider.createRuntimeCapability('platform.agent_execution.runner.factory');
4576
4584
 
4585
+ // Invariants: this payload has no runtime imports; protocol streams are not exit evidence.
4586
+ // The device supervisor regression test enforces identical process supervision semantics.
4587
+ const AGENT_PROCESS_SUPERVISOR = String.raw`
4588
+ import ctypes, errno, json, os, signal, subprocess, sys, time
4589
+ owner = int(sys.argv[1])
4590
+ stopping = False
4591
+ strong = False
4592
+ if sys.platform.startswith('linux'):
4593
+ strong = ctypes.CDLL(None, use_errno=True).prctl(36, 1, 0, 0, 0) == 0
4594
+ def stop(*args):
4595
+ global stopping
4596
+ stopping = True
4597
+ signal.signal(signal.SIGTERM, stop)
4598
+ signal.signal(signal.SIGINT, stop)
4599
+ # The supervisor is the process-group leader. Its live PID reserves the group identity.
4600
+ os.write(3, b'{"ready":true}\n')
4601
+ try:
4602
+ if os.getppid() != owner: raise OSError('Original host exited before admission')
4603
+ child = subprocess.Popen(sys.argv[2:], close_fds=True)
4604
+ except OSError:
4605
+ os.write(3, json.dumps({'version': 1, 'state': 'not_started', 'coverage': 'descendants', 'exitCode': 127}).encode())
4606
+ sys.exit(0)
4607
+ # Only the protocol child owns stdin, so a closed transport still produces EPIPE.
4608
+ os.close(0)
4609
+ code = None
4610
+ deadline = None
4611
+ while True:
4612
+ if os.getppid() != owner: stopping = True
4613
+ if code is None:
4614
+ value = child.poll()
4615
+ if value is not None: code = value; stopping = True
4616
+ if stopping and deadline is None:
4617
+ deadline = time.monotonic() + 2
4618
+ os.killpg(os.getpgrp(), signal.SIGTERM)
4619
+ if deadline is not None and time.monotonic() >= deadline:
4620
+ if not strong:
4621
+ # No subreaper means escaped descendants cannot be certified. No receipt is emitted.
4622
+ os.killpg(os.getpgrp(), signal.SIGKILL)
4623
+ # Kill only still-waitable direct children. Orphans are adopted by this subreaper;
4624
+ # holding them until waitpid prevents PID reuse between selection and signalling.
4625
+ try:
4626
+ ids = open('/proc/self/task/' + str(os.getpid()) + '/children').read().split()
4627
+ for value in ids:
4628
+ try: os.kill(int(value), signal.SIGKILL)
4629
+ except ProcessLookupError: pass
4630
+ except OSError:
4631
+ os.killpg(os.getpgrp(), signal.SIGKILL)
4632
+ if stopping and strong:
4633
+ empty = False
4634
+ while True:
4635
+ try:
4636
+ pid, status = os.waitpid(-1, os.WNOHANG)
4637
+ if pid == 0: break
4638
+ if pid == child.pid and code is None: code = os.waitstatus_to_exitcode(status)
4639
+ except ChildProcessError:
4640
+ empty = True
4641
+ break
4642
+ if empty:
4643
+ os.write(3, json.dumps({'version': 1, 'state': 'exited', 'coverage': 'descendants', 'exitCode': code}).encode())
4644
+ sys.exit(0)
4645
+ time.sleep(.02)
4646
+ `;
4647
+
4648
+ /** Persisted host ownership marker. Only built-in presets are supported. */ const managedAgentRuntimeSchema = v3.z.object({
4649
+ type: v3.z.literal('builtin'),
4650
+ version: v3.z.string().min(1)
4651
+ }).strict();
4652
+ /** Launch settings supplied by the installed strategy, never by tool input or host provider lists. */ const agentRuntimeDeploymentSpecSchema = v3.z.discriminatedUnion('type', [
4653
+ v3.z.object({
4654
+ type: v3.z.literal('process'),
4655
+ command: v3.z.string().min(1).refine((value)=>!value.includes('\0')),
4656
+ args: v3.z.array(v3.z.string().refine((value)=>!value.includes('\0'))),
4657
+ environment: v3.z.record(v3.z.string(), v3.z.string()),
4658
+ model: v3.z.string().min(1).optional(),
4659
+ timeoutMs: v3.z.number().int().min(1000).max(3600000)
4660
+ }).strict(),
4661
+ v3.z.object({
4662
+ type: v3.z.literal('sdk'),
4663
+ environment: v3.z.record(v3.z.string(), v3.z.string()),
4664
+ model: v3.z.string().min(1).optional(),
4665
+ timeoutMs: v3.z.number().int().min(1000).max(3600000)
4666
+ }).strict(),
4667
+ v3.z.object({
4668
+ type: v3.z.literal('service'),
4669
+ serverUrl: v3.z.string().url().refine((value)=>{
4670
+ try {
4671
+ const url = new URL(value);
4672
+ return [
4673
+ 'http:',
4674
+ 'https:'
4675
+ ].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
4676
+ } catch (e) {
4677
+ return false;
4678
+ }
4679
+ }),
4680
+ authorization: v3.z.string().optional(),
4681
+ timeoutMs: v3.z.number().int().min(1000).max(3600000)
4682
+ }).strict()
4683
+ ]);
4684
+ /** 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');
4685
+
4577
4686
  /** Host-only provenance. This describes a saved operation; it never grants access by itself. */ const projectPipelineInvocationScopeSchema = v3.z.object({
4578
4687
  tenantId: v3.z.string().uuid(),
4579
4688
  organizationId: v3.z.string().uuid(),
@@ -4593,6 +4702,69 @@ const AgentExecutionRunnerFactoryCapability = modelProvider.createRuntimeCapabil
4593
4702
 
4594
4703
  /** Older runtime plugins can still send this event; new emissions use ON_CHAT_EVENT. */ const RESOURCE_CARD_EVENT = 'xpert.resource_card';
4595
4704
 
4705
+ function middleware(node) {
4706
+ return node.type === 'workflow' && node.entity.type === contracts.WorkflowNodeTypeEnum.MIDDLEWARE;
4707
+ }
4708
+ function hasAssistantMiddleware(draft, provider) {
4709
+ return draft.nodes.some((node)=>middleware(node) && node.entity.provider === provider && draft.connections.some((edge)=>{
4710
+ var _draft_team_agent;
4711
+ 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;
4712
+ }));
4713
+ }
4714
+ /** Compose only the draft graph. The platform records the contribution for safe removal.
4715
+ * No Project, permission, external resource or implicit replacement is created here. */ function applyAssistantMiddleware(draft, input) {
4716
+ var _agent_entity_prompt;
4717
+ const agent = draft.nodes.find((node)=>{
4718
+ var _draft_team_agent;
4719
+ return node.type === 'agent' && node.key === ((_draft_team_agent = draft.team.agent) == null ? void 0 : _draft_team_agent.key);
4720
+ });
4721
+ if ((agent == null ? void 0 : agent.type) !== 'agent') throw new common.BadRequestException('assistant.invalid_draft');
4722
+ if (!hasAssistantMiddleware(draft, input.provider)) {
4723
+ var _agent_entity_options, _agent_entity_options_middlewares, _agent_entity_options1;
4724
+ let key = input.key;
4725
+ 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}`;
4726
+ const entity = {
4727
+ id: key,
4728
+ key,
4729
+ type: contracts.WorkflowNodeTypeEnum.MIDDLEWARE,
4730
+ title: input.title,
4731
+ provider: input.provider,
4732
+ required: true,
4733
+ options: {}
4734
+ };
4735
+ draft.nodes.push({
4736
+ type: 'workflow',
4737
+ key,
4738
+ position: {
4739
+ x: 620,
4740
+ y: 160 * (draft.nodes.length - 1)
4741
+ },
4742
+ entity
4743
+ });
4744
+ draft.connections.push({
4745
+ key: `${agent.key}/${key}`,
4746
+ type: 'workflow',
4747
+ from: agent.key,
4748
+ to: key,
4749
+ required: true
4750
+ });
4751
+ var _agent_entity_options_middlewares_order;
4752
+ agent.entity.options = _extends._extends({}, agent.entity.options, {
4753
+ parallelToolCalls: false,
4754
+ middlewares: _extends._extends({}, (_agent_entity_options = agent.entity.options) == null ? void 0 : _agent_entity_options.middlewares, {
4755
+ order: [
4756
+ ...(_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 : [],
4757
+ key
4758
+ ]
4759
+ })
4760
+ });
4761
+ }
4762
+ if (!((_agent_entity_prompt = agent.entity.prompt) == null ? void 0 : _agent_entity_prompt.includes(input.instructions))) agent.entity.prompt = [
4763
+ agent.entity.prompt,
4764
+ input.instructions
4765
+ ].filter(Boolean).join('\n\n');
4766
+ }
4767
+
4596
4768
  const ASSISTANT_CAPABILITY_PROVIDER = 'ASSISTANT_CAPABILITY_PROVIDER';
4597
4769
  const AssistantCapabilityProvider = (key)=>common.applyDecorators(common.SetMetadata(ASSISTANT_CAPABILITY_PROVIDER, key), common.SetMetadata(STRATEGY_META_KEY, ASSISTANT_CAPABILITY_PROVIDER));
4598
4770
  exports.AssistantCapabilityProviderRegistry = class AssistantCapabilityProviderRegistry extends BaseStrategyRegistry {
@@ -4959,26 +5131,59 @@ function resolveSandboxBackend(sandbox) {
4959
5131
  return isSandboxBackend(candidate) ? candidate : null;
4960
5132
  }
4961
5133
 
5134
+ const editMetricsSchema = v3.z.object({
5135
+ occurrences: v3.z.number().int().nonnegative(),
5136
+ oldLines: v3.z.number().int().nonnegative(),
5137
+ newLines: v3.z.number().int().nonnegative(),
5138
+ changed: v3.z.boolean(),
5139
+ diff: v3.z.object({
5140
+ removed: v3.z.number().int().nonnegative(),
5141
+ added: v3.z.number().int().nonnegative()
5142
+ }).optional(),
5143
+ diffUnavailable: v3.z.enum([
5144
+ 'comparison_budget_exceeded',
5145
+ 'diff_unavailable'
5146
+ ]).optional()
5147
+ });
5148
+ function editMetrics(output) {
5149
+ try {
5150
+ const result = editMetricsSchema.safeParse(JSON.parse(output));
5151
+ if (!result.success) return undefined;
5152
+ const _result_data = result.data, { diff } = _result_data, metrics = _object_without_properties_loose$2._object_without_properties_loose(_result_data, [
5153
+ "diff"
5154
+ ]);
5155
+ return _extends._extends({}, metrics, diff ? {
5156
+ diff: {
5157
+ removed: diff.removed,
5158
+ added: diff.added
5159
+ }
5160
+ } : {});
5161
+ } catch (e) {
5162
+ return undefined;
5163
+ }
5164
+ }
4962
5165
  function editCommandResult(filePath, result) {
5166
+ const metrics = editMetrics(result.output);
4963
5167
  switch(result.exitCode){
4964
5168
  case 0:
4965
- return {
5169
+ return _extends._extends({
4966
5170
  path: filePath,
4967
- filesUpdate: null,
5171
+ filesUpdate: null
5172
+ }, metrics != null ? metrics : {
4968
5173
  occurrences: parseInt(result.output.trim(), 10) || 1
4969
- };
5174
+ });
4970
5175
  case 1:
4971
- return {
5176
+ return _extends._extends({}, metrics, {
4972
5177
  error: `String not found in file '${filePath}'`
4973
- };
5178
+ });
4974
5179
  case 2:
4975
- return {
5180
+ return _extends._extends({}, metrics, {
4976
5181
  error: `Multiple occurrences found in '${filePath}'. Use replaceAll=true to replace all.`
4977
- };
5182
+ });
4978
5183
  case 3:
4979
- return {
5184
+ return _extends._extends({}, metrics, {
4980
5185
  error: `Error: File '${filePath}' not found`
4981
- };
5186
+ });
4982
5187
  default:
4983
5188
  return {
4984
5189
  error: `Unknown error editing file '${filePath}'`
@@ -5020,6 +5225,88 @@ function editCommandResult(filePath, result) {
5020
5225
  };
5021
5226
  }
5022
5227
 
5228
+ // Embedded in the existing sandbox Node process; no Git, subprocess, or temporary files.
5229
+ const FILE_EDIT_DIFF_SCRIPT = String.raw`
5230
+ function inspectLineDiff(before, after) {
5231
+ if (before === after) return { diff: { removed: 0, added: 0 } };
5232
+ // Include line terminators so a missing final newline is an actual line change.
5233
+ const oldLines = before.match(/[^\n]*\n|[^\n]+$/g) || [];
5234
+ const newLines = after.match(/[^\n]*\n|[^\n]+$/g) || [];
5235
+ let start = 0, oldEnd = oldLines.length, newEnd = newLines.length;
5236
+ while (start < oldEnd && start < newEnd && oldLines[start] === newLines[start]) start++;
5237
+ while (oldEnd > start && newEnd > start && oldLines[oldEnd - 1] === newLines[newEnd - 1]) {
5238
+ oldEnd--;
5239
+ newEnd--;
5240
+ }
5241
+ const removed = oldEnd - start, added = newEnd - start;
5242
+ if (!removed || !added) return { diff: { removed, added } };
5243
+
5244
+ // Myers shortest edit distance needs only a frontier when reporting counts, not a patch.
5245
+ // Bound the optional quadratic search on broad rewrites; never limit the edit itself.
5246
+ const maxDistance = Math.min(removed + added, 2000);
5247
+ const offset = maxDistance + 1;
5248
+ const frontier = new Int32Array(2 * maxDistance + 3);
5249
+ let work = 0;
5250
+ for (let distance = 0; distance <= maxDistance; distance++) {
5251
+ for (let diagonal = -distance; diagonal <= distance; diagonal += 2) {
5252
+ if (++work > 1000000) return { diffUnavailable: 'comparison_budget_exceeded' };
5253
+ const index = offset + diagonal;
5254
+ let x = diagonal === -distance || (diagonal !== distance && frontier[index - 1] < frontier[index + 1])
5255
+ ? frontier[index + 1]
5256
+ : frontier[index - 1] + 1;
5257
+ let y = x - diagonal;
5258
+ while (x < removed && y < added && oldLines[start + x] === newLines[start + y]) {
5259
+ if (++work > 1000000) return { diffUnavailable: 'comparison_budget_exceeded' };
5260
+ x++;
5261
+ y++;
5262
+ }
5263
+ if (x >= removed && y >= added) {
5264
+ return { diff: { removed: (distance + removed - added) / 2, added: (distance + added - removed) / 2 } };
5265
+ }
5266
+ frontier[index] = x;
5267
+ }
5268
+ }
5269
+ return { diffUnavailable: 'comparison_budget_exceeded' };
5270
+ }
5271
+ `;
5272
+
5273
+ /** Compare actual file contents inside the sandbox; reporting must never prevent an edit. */ function buildEditCommand(filePath, oldString, newString, replaceAll) {
5274
+ const encoded = Buffer.from(JSON.stringify({
5275
+ filePath,
5276
+ oldString,
5277
+ newString,
5278
+ replaceAll
5279
+ })).toString('base64');
5280
+ const script = `
5281
+ const fs = require('node:fs');
5282
+ const input = JSON.parse(Buffer.from('${encoded}', 'base64').toString('utf8'));
5283
+ const lines = text => text.length ? text.split('\\n').length - Number(text.endsWith('\\n')) : 0;
5284
+ const metrics = { oldLines: lines(input.oldString), newLines: lines(input.newString) };
5285
+
5286
+ ${FILE_EDIT_DIFF_SCRIPT}
5287
+
5288
+ function unchanged(exitCode) {
5289
+ console.log(JSON.stringify({ ...metrics, occurrences: 0, changed: false, diff: { removed: 0, added: 0 } }));
5290
+ process.exit(exitCode);
5291
+ }
5292
+ let before;
5293
+ try { before = fs.readFileSync(input.filePath, 'utf8'); } catch { unchanged(3); }
5294
+ const occurrences = before.split(input.oldString).length - 1;
5295
+ if (occurrences === 0) unchanged(1);
5296
+ if (occurrences > 1 && !input.replaceAll) unchanged(2);
5297
+ const after = before.split(input.oldString).join(input.newString);
5298
+ const changed = before !== after;
5299
+ if (changed) fs.writeFileSync(input.filePath, after, 'utf8');
5300
+ try {
5301
+ Object.assign(metrics, inspectLineDiff(before, after));
5302
+ } catch {
5303
+ metrics.diffUnavailable = 'diff_unavailable';
5304
+ }
5305
+ console.log(JSON.stringify({ ...metrics, occurrences, changed }));
5306
+ `;
5307
+ return `node -e '${script.replace(/'/g, "'\\''")}'`;
5308
+ }
5309
+
5023
5310
  const MAX_LINE_LENGTH = 500;
5024
5311
  const MAX_GREP_LINE_LENGTH = 2000;
5025
5312
  const GREP_RESULT_LIMIT = 100;
@@ -5519,41 +5806,6 @@ fs.appendFileSync(filePath, content, 'utf-8');
5519
5806
  console.log('OK');
5520
5807
  "`;
5521
5808
  }
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
5809
  /**
5558
5810
  * Node.js command template for grep operations.
5559
5811
  */ function buildGrepCommand(pattern, searchPath, globPattern) {
@@ -6013,6 +6265,8 @@ function normalizePluginJobProcessorMetadata(options) {
6013
6265
  pluginName,
6014
6266
  queueName,
6015
6267
  jobName
6268
+ }, options.controlContract === undefined ? {} : {
6269
+ controlContract: requireManagedQueueDecoratorValue(options.controlContract, 'controlContract')
6016
6270
  }, concurrency === undefined ? {} : {
6017
6271
  concurrency: Math.trunc(concurrency)
6018
6272
  });
@@ -6557,6 +6811,162 @@ exports.ArtifactPresentationRegistry = __decorate([
6557
6811
  ])
6558
6812
  ], exports.ArtifactPresentationRegistry);
6559
6813
 
6814
+ /** Package exports are a runtime boundary; reject malformed declarations before registration. */ const artifactTypeDefinitionSchema = v3.z.object({
6815
+ title: v3.z.object({
6816
+ en_US: v3.z.string().trim().min(1).max(200),
6817
+ zh_Hans: v3.z.string().trim().min(1).max(200).optional(),
6818
+ zh_Hant: v3.z.string().trim().min(1).max(200).optional()
6819
+ }).strict().optional(),
6820
+ kinds: v3.z.array(v3.z.enum([
6821
+ 'html',
6822
+ 'markdown',
6823
+ 'pdf',
6824
+ 'pptx',
6825
+ 'image',
6826
+ 'file',
6827
+ 'site',
6828
+ 'presentation'
6829
+ ])).min(1),
6830
+ collection: v3.z.object({
6831
+ allowCopy: v3.z.boolean()
6832
+ }).strict().optional(),
6833
+ content: v3.z.object({
6834
+ mimeTypes: v3.z.array(v3.z.string().min(1)).min(1),
6835
+ maxBytes: v3.z.number().int().positive()
6836
+ }).strict().optional(),
6837
+ sharing: v3.z.object({
6838
+ accessModes: v3.z.array(v3.z.enum([
6839
+ 'owner_only',
6840
+ 'workspace_all',
6841
+ 'organization_all',
6842
+ 'custom_principals',
6843
+ 'public_link',
6844
+ 'signed_preview'
6845
+ ])).min(1),
6846
+ versionModes: v3.z.array(v3.z.enum([
6847
+ 'latest',
6848
+ 'version'
6849
+ ])).min(1),
6850
+ maxTtlSeconds: v3.z.number().int().positive().optional(),
6851
+ allowDownload: v3.z.boolean(),
6852
+ mutableLinks: v3.z.boolean(),
6853
+ descriptor: v3.z.boolean(),
6854
+ shareKey: v3.z.string().min(1).optional()
6855
+ }).strict().optional(),
6856
+ presentation: v3.z.object({
6857
+ mode: v3.z.enum([
6858
+ 'file',
6859
+ 'snapshot',
6860
+ 'authenticated'
6861
+ ])
6862
+ }).strict()
6863
+ }).strict();
6864
+
6865
+ const artifactTypeKey = (type)=>JSON.stringify([
6866
+ type.pluginName,
6867
+ type.resourceType
6868
+ ]);
6869
+ const FILE_ARTIFACT_TYPE = {
6870
+ pluginName: '@xpert-ai/platform',
6871
+ resourceType: 'file'
6872
+ };
6873
+ /** Bindings pin registration scope. Removal never falls back to a different installation or plain file. */ exports.ArtifactTypeRegistry = class ArtifactTypeRegistry extends BaseStrategyRegistry {
6874
+ upsert(instance) {
6875
+ const target = resolveStrategyMetadataTarget(instance);
6876
+ const resourceType = target ? this.reflector.get(ARTIFACT_TYPE_PROVIDER, target) : undefined;
6877
+ if (!resourceType) return;
6878
+ const provider = instance;
6879
+ const source = this.getSource(provider);
6880
+ // Built-ins are explicitly composed by the host, never inferred from missing loader metadata.
6881
+ if (source.kind !== 'plugin') return;
6882
+ this.register(artifactTypeKey({
6883
+ pluginName: source.pluginName,
6884
+ resourceType
6885
+ }), provider, source);
6886
+ }
6887
+ registerBuiltin(type, provider) {
6888
+ this.register(artifactTypeKey(type), provider, {
6889
+ kind: 'builtin',
6890
+ scopeKey: BUILTIN_GLOBAL_SCOPE
6891
+ });
6892
+ }
6893
+ assertCanRegister(key, provider, source) {
6894
+ var _provider_snapshot, _this_strategies_get;
6895
+ if (!(provider == null ? void 0 : provider.definition) || typeof provider.authorize !== 'function' || typeof provider.validateContent !== 'function') throw new Error('ARTIFACT_TYPE_INVALID');
6896
+ artifactTypeDefinitionSchema.parse(provider.definition);
6897
+ const identity = JSON.parse(key);
6898
+ if (!Array.isArray(identity) || identity.length !== 2 || identity.some((value)=>typeof value !== 'string' || !value.trim())) throw new Error('ARTIFACT_TYPE_INVALID');
6899
+ if (source.kind === 'plugin' && (identity[0] !== source.pluginName || source.pluginName === '@xpert-ai/platform')) throw new Error('ARTIFACT_TYPE_NAMESPACE_DENIED');
6900
+ if (source.kind === 'plugin' && ((_provider_snapshot = provider.snapshot) == null ? void 0 : _provider_snapshot.kind) === 'host') throw new Error('ARTIFACT_TYPE_HOST_VIEW_DENIED');
6901
+ if (provider.definition.presentation.mode === 'snapshot' && !provider.snapshot) throw new Error('ARTIFACT_TYPE_SNAPSHOT_REQUIRED');
6902
+ if (provider.snapshot && (provider.definition.presentation.mode !== 'snapshot' || typeof provider.snapshot.read !== 'function' || provider.snapshot.kind === 'plugin' && typeof provider.snapshot.getEntry !== 'function')) throw new Error('ARTIFACT_TYPE_INVALID');
6903
+ const existing = (_this_strategies_get = this.strategies.get(source.scopeKey)) == null ? void 0 : _this_strategies_get.get(key);
6904
+ if (existing && existing !== provider) {
6905
+ const owner = this.getSource(existing);
6906
+ if (owner.kind !== source.kind || source.kind === 'builtin' || owner.kind === 'plugin' && source.kind === 'plugin' && owner.pluginName !== source.pluginName) throw new Error('ARTIFACT_TYPE_CONFLICT');
6907
+ }
6908
+ for (const [scope, entries] of this.strategies){
6909
+ if ([
6910
+ ...entries.values()
6911
+ ].includes(provider) && scope !== source.scopeKey) throw new Error('ARTIFACT_TYPE_SCOPE_CONFLICT');
6912
+ }
6913
+ super.assertCanRegister(key, provider, source);
6914
+ }
6915
+ bind(type, scope) {
6916
+ var _this_strategies_get;
6917
+ if (!scope.tenantId) throw new Error('ARTIFACT_TYPE_SCOPE_REQUIRED');
6918
+ const tenantScope = scope.tenantId === getDefaultTenantId() ? GLOBAL_ORGANIZATION_SCOPE : getTenantGlobalScopeKey(scope.tenantId);
6919
+ const scopes = [
6920
+ ...new Set([
6921
+ scope.organizationId,
6922
+ tenantScope,
6923
+ SYSTEM_GLOBAL_SCOPE,
6924
+ BUILTIN_GLOBAL_SCOPE
6925
+ ].filter(Boolean))
6926
+ ];
6927
+ const key = artifactTypeKey(type);
6928
+ for (const scopeKey of scopes)if ((_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.has(key)) return _extends._extends({}, type, {
6929
+ scopeKey
6930
+ });
6931
+ throw new Error('ARTIFACT_TYPE_UNAVAILABLE');
6932
+ }
6933
+ hasType(type, scope) {
6934
+ try {
6935
+ this.bind(type, scope);
6936
+ return true;
6937
+ } catch (e) {
6938
+ return false;
6939
+ }
6940
+ }
6941
+ requireBinding(binding, scope) {
6942
+ var _this_strategies_get;
6943
+ if (!binding || !scope.tenantId) throw new Error('ARTIFACT_TYPE_UNAVAILABLE');
6944
+ const tenantScope = scope.tenantId === getDefaultTenantId() ? GLOBAL_ORGANIZATION_SCOPE : getTenantGlobalScopeKey(scope.tenantId);
6945
+ if (![
6946
+ scope.organizationId,
6947
+ tenantScope,
6948
+ SYSTEM_GLOBAL_SCOPE,
6949
+ BUILTIN_GLOBAL_SCOPE
6950
+ ].includes(binding.scopeKey)) throw new Error('ARTIFACT_TYPE_SCOPE_DENIED');
6951
+ const provider = (_this_strategies_get = this.strategies.get(binding.scopeKey)) == null ? void 0 : _this_strategies_get.get(artifactTypeKey(binding));
6952
+ if (!provider) throw new Error('ARTIFACT_TYPE_UNAVAILABLE');
6953
+ return provider;
6954
+ }
6955
+ constructor(discovery, reflector){
6956
+ super(ARTIFACT_TYPE_PROVIDER, discovery, reflector);
6957
+ }
6958
+ };
6959
+ exports.ArtifactTypeRegistry = __decorate([
6960
+ common.Injectable(),
6961
+ __metadata("design:paramtypes", [
6962
+ core.DiscoveryService,
6963
+ core.Reflector
6964
+ ])
6965
+ ], exports.ArtifactTypeRegistry);
6966
+
6967
+ const ARTIFACT_TYPE_PROVIDER = 'XPERT_ARTIFACT_TYPE_PROVIDER';
6968
+ /** The loader supplies plugin identity. A contribution cannot select another plugin's namespace. */ const ArtifactTypeProvider = (resourceType)=>common.applyDecorators(common.SetMetadata(ARTIFACT_TYPE_PROVIDER, resourceType), common.SetMetadata(STRATEGY_META_KEY, ARTIFACT_TYPE_PROVIDER));
6969
+
6560
6970
  /** Platform-owned real-time collaboration capability available to scoped plugin runtimes. */ const CollaborationRuntimeCapability = modelProvider.createRuntimeCapability('platform.collaboration', {
6561
6971
  description: 'Create, synchronize, persist, authorize, and observe platform-managed real-time collaboration documents.'
6562
6972
  });
@@ -6585,9 +6995,19 @@ const ContentReferencesRuntimeCapability = modelProvider.createRuntimeCapability
6585
6995
  description: 'Authorized durable document references; plugins provide source-specific listing and files.'
6586
6996
  });
6587
6997
 
6998
+ /** Matching semantic type alone never grants a writer access to an incompatible native model. */ function supportsContentModel(editor, model, access) {
6999
+ 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));
7000
+ }
7001
+
6588
7002
  function isTextContentEditor(provider) {
6589
7003
  return provider.descriptor.kind === 'text-document';
6590
7004
  }
7005
+ function isFileContentEditor(provider) {
7006
+ return provider.descriptor.kind === 'file';
7007
+ }
7008
+ function isResourceContentEditor(provider) {
7009
+ return provider.descriptor.kind === 'resource';
7010
+ }
6591
7011
  const EDITOR_PROVIDER = 'XPERT_CONTENT_EDITOR_PROVIDER';
6592
7012
  const ContentEditorProvider = (key)=>common.applyDecorators(common.SetMetadata(EDITOR_PROVIDER, key), common.SetMetadata(STRATEGY_META_KEY, EDITOR_PROVIDER));
6593
7013
  exports.ContentEditorRegistry = class ContentEditorRegistry extends BaseStrategyRegistry {
@@ -10885,6 +11305,7 @@ Object.defineProperty(exports, "resourceCardId", {
10885
11305
  exports.ActorTokenRuntimeCapability = modelProvider.ActorTokenRuntimeCapability;
10886
11306
  exports.ActorTokenRuntimeFactoryCapability = modelProvider.ActorTokenRuntimeFactoryCapability;
10887
11307
  exports.ArtifactDraftsRuntimeCapability = modelProvider.ArtifactDraftsRuntimeCapability;
11308
+ exports.ArtifactLibraryRuntimeCapability = modelProvider.ArtifactLibraryRuntimeCapability;
10888
11309
  exports.ArtifactsRuntimeCapability = modelProvider.ArtifactsRuntimeCapability;
10889
11310
  exports.AssistantMiddlewareAccessRuntimeCapability = modelProvider.AssistantMiddlewareAccessRuntimeCapability;
10890
11311
  exports.BaseTool = modelProvider.BaseTool;
@@ -10916,10 +11337,6 @@ exports.workspaceFileMutationMetadata = modelProvider.workspaceFileMutationMetad
10916
11337
  exports.workspaceFileMutationPath = modelProvider.workspaceFileMutationPath;
10917
11338
  exports.workspaceRelativeFilePathSchema = modelProvider.workspaceRelativeFilePathSchema;
10918
11339
  exports.DataSourceRuntimeCapability = dataWorkbench.DataSourceRuntimeCapability;
10919
- exports.SqlDatabaseWorkbenchAdapter = dataWorkbench.SqlDatabaseWorkbenchAdapter;
10920
- exports.quoteDatabaseIdentifier = dataWorkbench.quoteDatabaseIdentifier;
10921
- exports.requireReadStatement = dataWorkbench.requireReadStatement;
10922
- exports.splitWorkbenchSql = dataWorkbench.splitWorkbenchSql;
10923
11340
  exports.analyticsBindingObjectSchema = analyticsResult.analyticsBindingObjectSchema;
10924
11341
  exports.analyticsBindingSchema = analyticsResult.analyticsBindingSchema;
10925
11342
  exports.analyticsControlsSchema = analyticsResult.analyticsControlsSchema;
@@ -10955,6 +11372,7 @@ exports.ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN = ACCOUNT_BINDING_PERMISSION_SE
10955
11372
  exports.AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING;
10956
11373
  exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
10957
11374
  exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
11375
+ exports.AGENT_PROCESS_SUPERVISOR = AGENT_PROCESS_SUPERVISOR;
10958
11376
  exports.AGENT_RUNTIME_EVENT_MESSAGE_TYPE = AGENT_RUNTIME_EVENT_MESSAGE_TYPE;
10959
11377
  exports.AGENT_RUNTIME_STRATEGY = AGENT_RUNTIME_STRATEGY;
10960
11378
  exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
@@ -10962,12 +11380,14 @@ exports.AIModelProviderStrategy = AIModelProviderStrategy;
10962
11380
  exports.AI_MODEL_PROVIDER = AI_MODEL_PROVIDER;
10963
11381
  exports.ANALYTICS_PROVIDER = ANALYTICS_PROVIDER;
10964
11382
  exports.ARTIFACT_PRESENTATION_PROVIDER = ARTIFACT_PRESENTATION_PROVIDER;
11383
+ exports.ARTIFACT_TYPE_PROVIDER = ARTIFACT_TYPE_PROVIDER;
10965
11384
  exports.ASSISTANT_CAPABILITY_PROVIDER = ASSISTANT_CAPABILITY_PROVIDER;
10966
11385
  exports.AdapterDataSourceStrategy = AdapterDataSourceStrategy;
10967
11386
  exports.AgentExecutionRunnerCapability = AgentExecutionRunnerCapability;
10968
11387
  exports.AgentExecutionRunnerFactoryCapability = AgentExecutionRunnerFactoryCapability;
10969
11388
  exports.AgentInvocationRuntimeCapability = AgentInvocationRuntimeCapability;
10970
11389
  exports.AgentMiddlewareStrategy = AgentMiddlewareStrategy;
11390
+ exports.AgentRuntimeDeploymentCapability = AgentRuntimeDeploymentCapability;
10971
11391
  exports.AgentRuntimeFactoryCapability = AgentRuntimeFactoryCapability;
10972
11392
  exports.AgentRuntimeStrategy = AgentRuntimeStrategy;
10973
11393
  exports.AiModelNotFoundException = AiModelNotFoundException;
@@ -10975,6 +11395,7 @@ exports.AnalyticsDefinitionAuthoringCapability = AnalyticsDefinitionAuthoringCap
10975
11395
  exports.AnalyticsProvider = AnalyticsProvider;
10976
11396
  exports.AnalyticsRuntimeCapability = AnalyticsRuntimeCapability;
10977
11397
  exports.ArtifactPresentationProvider = ArtifactPresentationProvider;
11398
+ exports.ArtifactTypeProvider = ArtifactTypeProvider;
10978
11399
  exports.AssistantCapabilityProvider = AssistantCapabilityProvider;
10979
11400
  exports.AssistantTaskRuntimeCapability = AssistantTaskRuntimeCapability;
10980
11401
  exports.BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN = BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN;
@@ -11035,6 +11456,8 @@ exports.EvolutionBaselineRuntimeCapability = EvolutionBaselineRuntimeCapability;
11035
11456
  exports.EvolutionChangeRuntimeCapability = EvolutionChangeRuntimeCapability;
11036
11457
  exports.EvolutionRuntimeCapability = EvolutionRuntimeCapability;
11037
11458
  exports.EvolutionTargetProviderStrategy = EvolutionTargetProviderStrategy;
11459
+ exports.ExecutionObservabilityRuntimeCapability = ExecutionObservabilityRuntimeCapability;
11460
+ exports.FILE_ARTIFACT_TYPE = FILE_ARTIFACT_TYPE;
11038
11461
  exports.FILE_STORAGE_PROVIDER = FILE_STORAGE_PROVIDER;
11039
11462
  exports.FILE_UPLOAD_TARGET_STRATEGY = FILE_UPLOAD_TARGET_STRATEGY;
11040
11463
  exports.FileRuntimeCapability = FileRuntimeCapability;
@@ -11179,6 +11602,7 @@ exports.XpertToolProvider = XpertToolProvider;
11179
11602
  exports.agentInvocationDispatchContextSchema = agentInvocationDispatchContextSchema;
11180
11603
  exports.agentRuntimeConsumptionStateSchema = agentRuntimeConsumptionStateSchema;
11181
11604
  exports.agentRuntimeDeliveryStateSchema = agentRuntimeDeliveryStateSchema;
11605
+ exports.agentRuntimeDeploymentSpecSchema = agentRuntimeDeploymentSpecSchema;
11182
11606
  exports.agentRuntimeEventMessageId = agentRuntimeEventMessageId;
11183
11607
  exports.agentRuntimeEventSchema = agentRuntimeEventSchema;
11184
11608
  exports.agentRuntimeReplyTargetSchema = agentRuntimeReplyTargetSchema;
@@ -11186,9 +11610,11 @@ exports.agentRuntimeResultClaimSchema = agentRuntimeResultClaimSchema;
11186
11610
  exports.agentRuntimeResultConsumptionKey = agentRuntimeResultConsumptionKey;
11187
11611
  exports.als = als;
11188
11612
  exports.appendSandboxMessage = appendSandboxMessage;
11613
+ exports.applyAssistantMiddleware = applyAssistantMiddleware;
11189
11614
  exports.applyModelConfiguration = applyModelConfiguration;
11190
11615
  exports.applyModelContextSize = applyModelContextSize;
11191
11616
  exports.artifactPresentationKey = artifactPresentationKey;
11617
+ exports.artifactTypeKey = artifactTypeKey;
11192
11618
  exports.buildSandboxTimeoutMessage = buildSandboxTimeoutMessage;
11193
11619
  exports.calcTokenUsage = calcTokenUsage;
11194
11620
  exports.calculateLLMUsagePrice = calculateLLMUsagePrice;
@@ -11224,12 +11650,16 @@ exports.getRequestContext = getRequestContext;
11224
11650
  exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
11225
11651
  exports.getTenantGlobalScopeKey = getTenantGlobalScopeKey;
11226
11652
  exports.getXpertToolMethod = getXpertToolMethod;
11653
+ exports.hasAssistantMiddleware = hasAssistantMiddleware;
11227
11654
  exports.isAgentInvocationTerminal = isAgentInvocationTerminal;
11228
11655
  exports.isDevelopmentSandboxRuntimeEnvironment = isDevelopmentSandboxRuntimeEnvironment;
11656
+ exports.isExecutionObservationSession = isExecutionObservationSession;
11657
+ exports.isFileContentEditor = isFileContentEditor;
11229
11658
  exports.isModelOutputValidationError = isModelOutputValidationError;
11230
11659
  exports.isModelUsagePricingConfig = isModelUsagePricingConfig;
11231
11660
  exports.isPluginArtifactNamespace = isPluginArtifactNamespace;
11232
11661
  exports.isRemoteFile = isRemoteFile;
11662
+ exports.isResourceContentEditor = isResourceContentEditor;
11233
11663
  exports.isSandboxBackend = isSandboxBackend;
11234
11664
  exports.isSandboxManagedServiceAdapter = isSandboxManagedServiceAdapter;
11235
11665
  exports.isSandboxServiceProxyAdapter = isSandboxServiceProxyAdapter;
@@ -11241,6 +11671,7 @@ exports.isTextContentEditor = isTextContentEditor;
11241
11671
  exports.jsonEncodedSchema = jsonEncodedSchema;
11242
11672
  exports.knowledgebaseActions = knowledgebaseActions;
11243
11673
  exports.loadYamlFile = loadYamlFile;
11674
+ exports.managedAgentRuntimeSchema = managedAgentRuntimeSchema;
11244
11675
  exports.mergeCredentials = mergeCredentials;
11245
11676
  exports.mergeModelRequirements = mergeModelRequirements;
11246
11677
  exports.mergeParentChildChunks = mergeParentChildChunks;
@@ -11270,6 +11701,7 @@ exports.runtimeToolProviderComponent = runtimeToolProviderComponent;
11270
11701
  exports.secondsToMilliseconds = secondsToMilliseconds;
11271
11702
  exports.setDefaultTenantId = setDefaultTenantId;
11272
11703
  exports.sumTokenUsage = sumTokenUsage;
11704
+ exports.supportsContentModel = supportsContentModel;
11273
11705
  exports.taskWaitReason = taskWaitReason;
11274
11706
  exports.textTokenBoundaries = textTokenBoundaries;
11275
11707
  exports.validateAnalyticsPayload = validateAnalyticsPayload;