@portel/photon 1.18.0 → 1.19.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/dist/auto-ui/beam.d.ts.map +1 -1
- package/dist/auto-ui/beam.js +14 -4
- package/dist/auto-ui/beam.js.map +1 -1
- package/dist/beam-form.bundle.js +5 -3
- package/dist/beam-form.bundle.js.map +2 -2
- package/dist/beam.bundle.js +686 -30
- package/dist/beam.bundle.js.map +3 -3
- package/dist/claude-code-plugin.js +1 -1
- package/dist/cli/commands/beam.d.ts.map +1 -1
- package/dist/cli/commands/beam.js +8 -2
- package/dist/cli/commands/beam.js.map +1 -1
- package/dist/cli/commands/changelog.d.ts +9 -0
- package/dist/cli/commands/changelog.d.ts.map +1 -0
- package/dist/cli/commands/changelog.js +133 -0
- package/dist/cli/commands/changelog.js.map +1 -0
- package/dist/cli/commands/maker.d.ts.map +1 -1
- package/dist/cli/commands/maker.js +23 -2
- package/dist/cli/commands/maker.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +53 -0
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/package.d.ts.map +1 -1
- package/dist/cli/commands/package.js +18 -2
- package/dist/cli/commands/package.js.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +1 -0
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/update.d.ts +3 -2
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +50 -43
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +16 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli-alias.js +1 -1
- package/dist/cli-alias.js.map +1 -1
- package/dist/context-store.d.ts +23 -33
- package/dist/context-store.d.ts.map +1 -1
- package/dist/context-store.js +147 -97
- package/dist/context-store.js.map +1 -1
- package/dist/context.d.ts +15 -10
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +37 -13
- package/dist/context.js.map +1 -1
- package/dist/daemon/server.js +4 -2
- package/dist/daemon/server.js.map +1 -1
- package/dist/data-migration.d.ts +27 -0
- package/dist/data-migration.d.ts.map +1 -0
- package/dist/data-migration.js +307 -0
- package/dist/data-migration.js.map +1 -0
- package/dist/editor-support/docblock-tag-catalog.d.ts.map +1 -1
- package/dist/editor-support/docblock-tag-catalog.js +6 -0
- package/dist/editor-support/docblock-tag-catalog.js.map +1 -1
- package/dist/loader.d.ts +10 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +97 -12
- package/dist/loader.js.map +1 -1
- package/dist/marketplace-manager.d.ts.map +1 -1
- package/dist/marketplace-manager.js +25 -5
- package/dist/marketplace-manager.js.map +1 -1
- package/dist/photon-cli-runner.d.ts.map +1 -1
- package/dist/photon-cli-runner.js +47 -21
- package/dist/photon-cli-runner.js.map +1 -1
- package/dist/photon-doc-extractor.d.ts +1 -0
- package/dist/photon-doc-extractor.d.ts.map +1 -1
- package/dist/photon-doc-extractor.js +6 -0
- package/dist/photon-doc-extractor.js.map +1 -1
- package/dist/readme-syncer.d.ts.map +1 -1
- package/dist/readme-syncer.js +6 -1
- package/dist/readme-syncer.js.map +1 -1
- package/dist/server.d.ts +40 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +143 -28
- package/dist/server.js.map +1 -1
- package/dist/shared/audit.js +4 -4
- package/dist/shared/audit.js.map +1 -1
- package/dist/tasks/store.d.ts.map +1 -1
- package/dist/tasks/store.js +6 -2
- package/dist/tasks/store.js.map +1 -1
- package/dist/version-notify.d.ts +27 -0
- package/dist/version-notify.d.ts.map +1 -0
- package/dist/version-notify.js +142 -0
- package/dist/version-notify.js.map +1 -0
- package/package.json +2 -2
- package/dist/auto-ui/bridge/openai-shim.d.ts +0 -20
- package/dist/auto-ui/bridge/openai-shim.d.ts.map +0 -1
- package/dist/auto-ui/bridge/openai-shim.js +0 -231
- package/dist/auto-ui/bridge/openai-shim.js.map +0 -1
- package/dist/auto-ui/bridge/photon-app.d.ts +0 -162
- package/dist/auto-ui/bridge/photon-app.d.ts.map +0 -1
- package/dist/auto-ui/bridge/photon-app.js +0 -460
- package/dist/auto-ui/bridge/photon-app.js.map +0 -1
- package/dist/auto-ui/daemon-tools.d.ts +0 -45
- package/dist/auto-ui/daemon-tools.d.ts.map +0 -1
- package/dist/auto-ui/daemon-tools.js +0 -581
- package/dist/auto-ui/daemon-tools.js.map +0 -1
- package/dist/auto-ui/design-system/index.d.ts +0 -21
- package/dist/auto-ui/design-system/index.d.ts.map +0 -1
- package/dist/auto-ui/design-system/index.js +0 -27
- package/dist/auto-ui/design-system/index.js.map +0 -1
- package/dist/auto-ui/design-system/transaction-ui.d.ts +0 -70
- package/dist/auto-ui/design-system/transaction-ui.d.ts.map +0 -1
- package/dist/auto-ui/design-system/transaction-ui.js +0 -982
- package/dist/auto-ui/design-system/transaction-ui.js.map +0 -1
- package/dist/auto-ui/playground-server.d.ts +0 -7
- package/dist/auto-ui/playground-server.d.ts.map +0 -1
- package/dist/auto-ui/playground-server.js +0 -840
- package/dist/auto-ui/playground-server.js.map +0 -1
- package/dist/auto-ui/rendering/components.d.ts +0 -29
- package/dist/auto-ui/rendering/components.d.ts.map +0 -1
- package/dist/auto-ui/rendering/components.js +0 -1341
- package/dist/auto-ui/rendering/components.js.map +0 -1
- package/dist/auto-ui/rendering/field-analyzer.d.ts +0 -104
- package/dist/auto-ui/rendering/field-analyzer.d.ts.map +0 -1
- package/dist/auto-ui/rendering/field-analyzer.js +0 -447
- package/dist/auto-ui/rendering/field-analyzer.js.map +0 -1
- package/dist/auto-ui/rendering/field-renderers.d.ts +0 -64
- package/dist/auto-ui/rendering/field-renderers.d.ts.map +0 -1
- package/dist/auto-ui/rendering/field-renderers.js +0 -317
- package/dist/auto-ui/rendering/field-renderers.js.map +0 -1
- package/dist/auto-ui/rendering/index.d.ts +0 -28
- package/dist/auto-ui/rendering/index.d.ts.map +0 -1
- package/dist/auto-ui/rendering/index.js +0 -60
- package/dist/auto-ui/rendering/index.js.map +0 -1
- package/dist/auto-ui/rendering/layout-selector.d.ts +0 -60
- package/dist/auto-ui/rendering/layout-selector.d.ts.map +0 -1
- package/dist/auto-ui/rendering/layout-selector.js +0 -476
- package/dist/auto-ui/rendering/layout-selector.js.map +0 -1
- package/dist/markdown-utils.d.ts +0 -8
- package/dist/markdown-utils.d.ts.map +0 -1
- package/dist/markdown-utils.js +0 -64
- package/dist/markdown-utils.js.map +0 -1
- package/dist/mcp-client.d.ts +0 -9
- package/dist/mcp-client.d.ts.map +0 -1
- package/dist/mcp-client.js +0 -11
- package/dist/mcp-client.js.map +0 -1
- package/dist/mcp-elicitation.d.ts +0 -32
- package/dist/mcp-elicitation.d.ts.map +0 -1
- package/dist/mcp-elicitation.js +0 -26
- package/dist/mcp-elicitation.js.map +0 -1
- package/dist/photons/builder-compass.photon.d.ts +0 -167
- package/dist/photons/builder-compass.photon.d.ts.map +0 -1
- package/dist/photons/builder-compass.photon.js +0 -816
- package/dist/photons/builder-compass.photon.js.map +0 -1
- package/dist/photons/builder-compass.photon.ts +0 -1129
- package/dist/photons/docs/ui/docs.html +0 -441
- package/dist/photons/docs.photon.d.ts +0 -237
- package/dist/photons/docs.photon.d.ts.map +0 -1
- package/dist/photons/docs.photon.js +0 -483
- package/dist/photons/docs.photon.js.map +0 -1
- package/dist/photons/docs.photon.ts +0 -536
- package/dist/photons/slides.photon.d.ts +0 -212
- package/dist/photons/slides.photon.d.ts.map +0 -1
- package/dist/photons/slides.photon.js +0 -355
- package/dist/photons/slides.photon.js.map +0 -1
- package/dist/photons/slides.photon.ts +0 -370
- package/dist/photons/spreadsheet/ui/spreadsheet.html +0 -779
- package/dist/photons/spreadsheet.photon.d.ts +0 -554
- package/dist/photons/spreadsheet.photon.d.ts.map +0 -1
- package/dist/photons/spreadsheet.photon.js +0 -1050
- package/dist/photons/spreadsheet.photon.js.map +0 -1
- package/dist/photons/spreadsheet.photon.ts +0 -1239
- package/dist/photons/ui/builder-compass.html +0 -1199
- package/dist/photons/ui/builder-compass.photon.html +0 -380
- package/dist/security-scanner.d.ts +0 -52
- package/dist/security-scanner.d.ts.map +0 -1
- package/dist/security-scanner.js +0 -181
- package/dist/security-scanner.js.map +0 -1
- package/dist/shared/performance.d.ts +0 -65
- package/dist/shared/performance.d.ts.map +0 -1
- package/dist/shared/performance.js +0 -136
- package/dist/shared/performance.js.map +0 -1
package/dist/loader.js
CHANGED
|
@@ -36,7 +36,7 @@ executionContext,
|
|
|
36
36
|
// Lock helper
|
|
37
37
|
withLock as withLockHelper,
|
|
38
38
|
// Middleware system
|
|
39
|
-
builtinRegistry, MiddlewareRegistry, buildMiddlewareChain, } from '@portel/photon-core';
|
|
39
|
+
builtinRegistry, MiddlewareRegistry, buildMiddlewareChain, detectNamespace, getCacheDir, } from '@portel/photon-core';
|
|
40
40
|
import { getDefaultContext } from './context.js';
|
|
41
41
|
import * as os from 'os';
|
|
42
42
|
import { MarketplaceManager } from './marketplace-manager.js';
|
|
@@ -332,7 +332,7 @@ export class PhotonLoader {
|
|
|
332
332
|
* Directory where MCP-specific dependencies are cached
|
|
333
333
|
*/
|
|
334
334
|
getDependencyCacheDir(cacheKey) {
|
|
335
|
-
return path.join(
|
|
335
|
+
return path.join(getCacheDir(), 'dependencies', cacheKey);
|
|
336
336
|
}
|
|
337
337
|
getBuildCacheDir(cacheKey) {
|
|
338
338
|
return path.join(this.getDependencyCacheDir(cacheKey), '.build');
|
|
@@ -402,7 +402,11 @@ export class PhotonLoader {
|
|
|
402
402
|
? this.dependenciesEqual(metadata.dependencies, dependencies)
|
|
403
403
|
: false;
|
|
404
404
|
const resolvedCoreVersion = getResolvedPhotonCoreVersion();
|
|
405
|
-
|
|
405
|
+
// Compare versions tolerantly: "2.17.6" matches "^2.17.6" and vice versa
|
|
406
|
+
// This prevents unnecessary cache clears when createRequire fallback returns a range
|
|
407
|
+
const storedVersion = metadata?.photonCoreVersion || '';
|
|
408
|
+
const coreVersionChanged = storedVersion !== resolvedCoreVersion &&
|
|
409
|
+
storedVersion.replace(/^[\^~]/, '') !== resolvedCoreVersion.replace(/^[\^~]/, '');
|
|
406
410
|
// Only clear dependency cache when deps or core version actually changed.
|
|
407
411
|
// Source-only changes just need a build cache clear (recompile is fast).
|
|
408
412
|
const needsDepClear = Boolean(metadata && (!depsMatch || coreVersionChanged));
|
|
@@ -457,24 +461,39 @@ export class PhotonLoader {
|
|
|
457
461
|
const message = error instanceof Error ? error.message : String(error);
|
|
458
462
|
return (message.includes('Cannot find package') ||
|
|
459
463
|
message.includes('ERR_MODULE_NOT_FOUND') ||
|
|
460
|
-
message.includes('Cannot find module')
|
|
464
|
+
message.includes('Cannot find module') ||
|
|
465
|
+
message.includes('require is not defined'));
|
|
461
466
|
}
|
|
462
467
|
static parseDependenciesFromSource(source) {
|
|
463
468
|
const deps = [];
|
|
469
|
+
// Only match @dependencies inside JSDoc blocks (/** ... */)
|
|
470
|
+
const jsdocBlocks = source.match(/\/\*\*[\s\S]*?\*\//g) || [];
|
|
471
|
+
const jsdocText = jsdocBlocks.join('\n');
|
|
464
472
|
const regex = /@dependencies\s+([^\r\n]+)/g;
|
|
465
473
|
let match;
|
|
466
|
-
while ((match = regex.exec(
|
|
474
|
+
while ((match = regex.exec(jsdocText)) !== null) {
|
|
467
475
|
const entries = match[1]
|
|
476
|
+
.replace(/\*\/$/, '') // strip trailing */ if on same line
|
|
468
477
|
.split(',')
|
|
469
478
|
.map((entry) => entry.trim())
|
|
470
479
|
.filter(Boolean);
|
|
471
480
|
for (const entry of entries) {
|
|
472
481
|
const atIndex = entry.lastIndexOf('@');
|
|
482
|
+
let name;
|
|
483
|
+
let version;
|
|
473
484
|
if (atIndex <= 0) {
|
|
485
|
+
// No version specified (e.g., "sharp") — default to latest
|
|
486
|
+
name = entry.trim();
|
|
487
|
+
version = '*';
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
name = entry.slice(0, atIndex).trim();
|
|
491
|
+
version = entry.slice(atIndex + 1).trim();
|
|
492
|
+
}
|
|
493
|
+
// Validate: npm package names are lowercase, may have @scope/, no spaces
|
|
494
|
+
if (name.includes(' ') || !/^(@[a-z0-9-]+\/)?[a-z0-9._-]+$/.test(name)) {
|
|
474
495
|
continue;
|
|
475
496
|
}
|
|
476
|
-
const name = entry.slice(0, atIndex).trim();
|
|
477
|
-
let version = entry.slice(atIndex + 1).trim();
|
|
478
497
|
// Trailing ? marks the dependency as optional (e.g. sharp@^0.33.0?)
|
|
479
498
|
const optional = version.endsWith('?');
|
|
480
499
|
if (optional) {
|
|
@@ -609,8 +628,9 @@ export class PhotonLoader {
|
|
|
609
628
|
this.logger.warn(`⚠️ ${name} loaded with configuration warnings:`);
|
|
610
629
|
this.logger.warn(String(configError));
|
|
611
630
|
}
|
|
612
|
-
// Set photon name for event source identification
|
|
631
|
+
// Set photon name and namespace for event source identification and data paths
|
|
613
632
|
instance._photonName = name;
|
|
633
|
+
instance._photonNamespace = this.resolveNamespace(absolutePath);
|
|
614
634
|
// Inject instance name for named instances (runtime concept, not code)
|
|
615
635
|
instance.instanceName = options?.instanceName ?? '';
|
|
616
636
|
// Inject file path for storage()/assets() resolution
|
|
@@ -702,11 +722,12 @@ export class PhotonLoader {
|
|
|
702
722
|
};
|
|
703
723
|
}
|
|
704
724
|
if (caps.has('memory')) {
|
|
705
|
-
// Inject lazy memory provider
|
|
725
|
+
// Inject lazy memory provider — capture baseDir from loader context
|
|
726
|
+
const memoryBaseDir = this.baseDir;
|
|
706
727
|
Object.defineProperty(instance, 'memory', {
|
|
707
728
|
get() {
|
|
708
729
|
if (!this._memory) {
|
|
709
|
-
this._memory = new MemoryProvider(name, this._sessionId);
|
|
730
|
+
this._memory = new MemoryProvider(name, this._sessionId, this._photonNamespace, memoryBaseDir);
|
|
710
731
|
}
|
|
711
732
|
return this._memory;
|
|
712
733
|
},
|
|
@@ -904,6 +925,42 @@ export class PhotonLoader {
|
|
|
904
925
|
}
|
|
905
926
|
this.log(`🔌 Injected channel event infrastructure into ${name}`);
|
|
906
927
|
}
|
|
928
|
+
// Inject this.channel() for channel notifications — works for both Photon
|
|
929
|
+
// subclasses and plain classes. Emits on '{photonName}:channel-push' daemon
|
|
930
|
+
// channel which the MCP server intercepts and translates to the client's
|
|
931
|
+
// notification method (e.g. notifications/claude/channel).
|
|
932
|
+
//
|
|
933
|
+
// this.channel(content, meta) — send a message to the client
|
|
934
|
+
// this.channel.respond(id, behavior) — respond to permission requests
|
|
935
|
+
// this.channel.onPermission(handler) — register permission request handler
|
|
936
|
+
if (typeof instance.emit === 'function') {
|
|
937
|
+
const emitFn = instance.emit.bind(instance);
|
|
938
|
+
// Permission handler stored locally — wired by server after load
|
|
939
|
+
let permissionHandler;
|
|
940
|
+
const channelFn = Object.assign((content, meta) => {
|
|
941
|
+
emitFn({
|
|
942
|
+
channel: `${name}:channel-push`,
|
|
943
|
+
event: 'channel',
|
|
944
|
+
data: { content, meta },
|
|
945
|
+
});
|
|
946
|
+
}, {
|
|
947
|
+
respond: (requestId, behavior) => {
|
|
948
|
+
emitFn({
|
|
949
|
+
channel: `${name}:channel-permission-response`,
|
|
950
|
+
event: 'permission-response',
|
|
951
|
+
data: { request_id: requestId, behavior },
|
|
952
|
+
});
|
|
953
|
+
},
|
|
954
|
+
onPermission: (handler) => {
|
|
955
|
+
permissionHandler = handler;
|
|
956
|
+
},
|
|
957
|
+
// Internal: called by the server when a permission request arrives
|
|
958
|
+
_dispatchPermission: (request) => {
|
|
959
|
+
permissionHandler?.(request);
|
|
960
|
+
},
|
|
961
|
+
});
|
|
962
|
+
instance.channel = channelFn;
|
|
963
|
+
}
|
|
907
964
|
// Check @cli dependencies (required system CLI tools)
|
|
908
965
|
if (tsContent) {
|
|
909
966
|
await this.checkCLIDependencies(tsContent, name);
|
|
@@ -1037,6 +1094,7 @@ export class PhotonLoader {
|
|
|
1037
1094
|
instance._photonConfigError = configError;
|
|
1038
1095
|
}
|
|
1039
1096
|
instance._photonName = name;
|
|
1097
|
+
instance._photonNamespace = this.resolveNamespace(absolutePath);
|
|
1040
1098
|
instance.instanceName = options?.instanceName ?? '';
|
|
1041
1099
|
// Inject file path for storage()/assets() resolution.
|
|
1042
1100
|
// For preloaded modules (compiled binaries), remap to ~/.photon/ so storage()
|
|
@@ -1116,10 +1174,11 @@ export class PhotonLoader {
|
|
|
1116
1174
|
};
|
|
1117
1175
|
}
|
|
1118
1176
|
if (caps.has('memory')) {
|
|
1177
|
+
const memoryBaseDir = this.baseDir;
|
|
1119
1178
|
Object.defineProperty(instance, 'memory', {
|
|
1120
1179
|
get() {
|
|
1121
1180
|
if (!this._memory) {
|
|
1122
|
-
this._memory = new MemoryProvider(name, this._sessionId);
|
|
1181
|
+
this._memory = new MemoryProvider(name, this._sessionId, this._photonNamespace, memoryBaseDir);
|
|
1123
1182
|
}
|
|
1124
1183
|
return this._memory;
|
|
1125
1184
|
},
|
|
@@ -1945,7 +2004,7 @@ export class PhotonLoader {
|
|
|
1945
2004
|
}
|
|
1946
2005
|
// If configured but failed, provide more specific error
|
|
1947
2006
|
throw new Error(`MCP "${dep.name}" is configured but failed to connect: ${errorMsg}\n` +
|
|
1948
|
-
`Check your
|
|
2007
|
+
`Check your config.json configuration and ensure:\n` +
|
|
1949
2008
|
` • The command/URL is correct\n` +
|
|
1950
2009
|
` • Required environment variables are set\n` +
|
|
1951
2010
|
` • The MCP server is accessible`);
|
|
@@ -2990,12 +3049,19 @@ Run: photon mcp ${mcpName} --config
|
|
|
2990
3049
|
return; // No emit function, can't wrap methods
|
|
2991
3050
|
}
|
|
2992
3051
|
// Get all public method names from the instance
|
|
3052
|
+
// Skip runtime-injected methods (emit, render, push, ask) — these are
|
|
3053
|
+
// capability methods injected by the loader, not user-defined tools
|
|
3054
|
+
const RUNTIME_METHODS = new Set(['emit', 'render', 'channel', 'ask', 'call']);
|
|
2993
3055
|
const proto = Object.getPrototypeOf(instance);
|
|
2994
3056
|
const methodNames = Object.getOwnPropertyNames(proto).filter((name) => {
|
|
2995
3057
|
// Skip constructor and private/protected methods
|
|
2996
3058
|
if (name === 'constructor' || name.startsWith('_')) {
|
|
2997
3059
|
return false;
|
|
2998
3060
|
}
|
|
3061
|
+
// Skip runtime-injected capability methods
|
|
3062
|
+
if (RUNTIME_METHODS.has(name)) {
|
|
3063
|
+
return false;
|
|
3064
|
+
}
|
|
2999
3065
|
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
3000
3066
|
return descriptor && typeof descriptor.value === 'function';
|
|
3001
3067
|
});
|
|
@@ -3211,6 +3277,25 @@ Run: photon mcp ${mcpName} --config
|
|
|
3211
3277
|
check.on('error', () => resolve(false));
|
|
3212
3278
|
});
|
|
3213
3279
|
}
|
|
3280
|
+
/**
|
|
3281
|
+
* Resolve the namespace for a photon based on its file path.
|
|
3282
|
+
* Extracts the directory name between baseDir and the photon file.
|
|
3283
|
+
*
|
|
3284
|
+
* Examples:
|
|
3285
|
+
* ~/.photon/portel-dev/todo.photon.ts → 'portel-dev'
|
|
3286
|
+
* ~/.photon/local/todo.photon.ts → 'local'
|
|
3287
|
+
* ~/.photon/todo.photon.ts → detected from git or 'local'
|
|
3288
|
+
*/
|
|
3289
|
+
resolveNamespace(absolutePath) {
|
|
3290
|
+
const rel = path.relative(this.baseDir, absolutePath);
|
|
3291
|
+
const parts = rel.split(path.sep);
|
|
3292
|
+
// If file is in a subdirectory (namespace/photon.ts), use that as namespace
|
|
3293
|
+
if (parts.length >= 2) {
|
|
3294
|
+
return parts[0];
|
|
3295
|
+
}
|
|
3296
|
+
// Flat file at root — detect from git remote or default to 'local'
|
|
3297
|
+
return detectNamespace(this.baseDir);
|
|
3298
|
+
}
|
|
3214
3299
|
/**
|
|
3215
3300
|
* Discover and extract assets from a Photon file
|
|
3216
3301
|
* Uses shared discoverAssets from photon-core for core logic,
|