@stacksjs/actions 0.75.599 → 0.75.602

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.
@@ -36,6 +36,14 @@ export declare function macosAgentRouteFiles(root: string): Promise<Array<{ file
36
36
  * router reports it on the request that uses it, as it would in development.
37
37
  */
38
38
  export declare function macosAgentActionFiles(root: string, sources: string[]): Record<string, string>;
39
+ /*.ts` first, then the framework defaults behind them.
40
+ *
41
+ * All of them, not only the ones the route files name. `csrf` is checked on
42
+ * every write without a route asking for it, a route group can name one from
43
+ * another file, and an alias map can point any name at any class, so reading
44
+ * the route files for names would miss the ones that matter most.
45
+ */
46
+ export declare function macosAgentMiddlewareFiles(root: string): Record<string, string>;
39
47
  /**
40
48
  * The agent launcher, written and compiled for the bundle. A compiled binary
41
49
  * cannot read route files off disk (the router refuses: they could not
@@ -1,4 +1,4 @@
1
1
  import{createHash}from"node:crypto";import{existsSync,mkdirSync,readdirSync,readFileSync,writeFileSync}from"node:fs";import{dirname,join,resolve}from"node:path";import process from"node:process";import{pathToFileURL}from"node:url";import{log}from"@stacksjs/cli";import{AGENT_MANIFEST,agentHostArguments,desktopLauncherCompileArgs,macosOutputDirectory,macosScreens,macosSelfUpdates,renderAgentEntry,validateMacosDesktop}from"@stacksjs/desktop-build";import{projectPath,storagePath}from"@stacksjs/path";import{craftBuilderVersion}from"./craft-entry";function entryFile(entry,root){try{return entry.startsWith("file:")?new URL(entry).pathname:Bun.resolveSync(entry,root)}catch{return null}}export function craftSupportsWebkit(source){return/\.webkit\b|[{,]\s*webkit\s*[,}=]/.test(source)}export function craftSupportsUpdater(source){return/\.updater\b|[{,]\s*updater\s*[,}=]/.test(source)}function craftMacosEntry(root){if(process.env.CRAFT_MACOS_SRC)return pathToFileURL(process.env.CRAFT_MACOS_SRC).href;try{const desktop=Bun.resolveSync("@stacksjs/desktop-build/package.json",root);return pathToFileURL(Bun.resolveSync("craft-native/macos",dirname(desktop))).href}catch{return"craft-native/macos"}}function hostKey(entry,root,webkit=false,updater=false){const hash=createHash("sha256");if(webkit)hash.update("webkit");if(updater)hash.update("updater");const path=entry.startsWith("file:")?new URL(entry).pathname:entry;const version=craftBuilderVersion(entry,root)?.version;hash.update(version??"unversioned");if(process.env.CRAFT_MACOS_SRC||!version){const templates=join(dirname(path),"../templates");if(existsSync(templates))for(const file of readdirSync(templates).sort())hash.update(readFileSync(join(templates,file)))}return hash.digest("hex").slice(0,16)}export async function prepareMacosNative(config,options={}){const root=options.root??projectPath();const errors=validateMacosDesktop(config);if(errors.length)throw new Error(`config/desktop.ts macos is not buildable:
2
2
  ${errors.map((error)=>` - ${error}`).join(`
3
- `)}`);if(process.platform!=="darwin")throw new Error("The native macOS app builds on macOS");const output=macosOutputDirectory(root,config);const work=join(output,".build");mkdirSync(work,{recursive:true});const screens=Object.fromEntries(Object.entries(macosScreens(config)).map(([name,file])=>[name,join(root,file)]));for(const[name,file]of Object.entries(screens))if(!existsSync(file))throw new Error(`macos.nativeScreens: screen "${name}" is ${file}, which does not exist`);const{compileNativeBundle}=await(process.env.STX_NATIVE_SRC?import(pathToFileURL(process.env.STX_NATIVE_SRC).href):import("@stacksjs/stx/native"));const app=config.nativeApp?join(root,config.nativeApp):undefined;const compiled=await compileNativeBundle({screens,initialScreen:config.initialScreen,minify:true,outFile:join(work,"native-screen.js"),root,...app?{app}:{},...config.shareStorage&&Object.keys(config.shareStorage).length?{shareStorage:{...config.shareStorage}}:{}});const problems=(compiled.diagnostics??[]).filter((item)=>item.message!=="dropped-subtree: script");for(const item of problems)await log.warn(`${item.file?`${item.file}: `:""}${item.message}`);if(problems.some((item)=>item.level==="error"))throw new Error("The native screens did not compile");const nativeBundle=compiled.outFile??join(work,"native-screen.js");const entry=craftMacosEntry(root);const webkit=config.webkit===true;if(webkit){const file=entryFile(entry,root);if(!file||!existsSync(file)||!craftSupportsWebkit(readFileSync(file,"utf8")))throw new Error(`macos.webkit needs a Craft whose buildMacOSNative links WebKit, and ${file??entry} does not. Upgrade craft-native, or point CRAFT_MACOS_SRC at a Craft checkout that has it.`)}let updater=macosSelfUpdates(config,options.distribution);if(updater){const file=entryFile(entry,root);if(!file||!existsSync(file)||!craftSupportsUpdater(readFileSync(file,"utf8"))){const reason=`macos.updates needs a Craft whose buildMacOSNative compiles the updater, and ${file??entry} does not. Upgrade craft-native, or point CRAFT_MACOS_SRC at a Craft checkout that has it.`;if(options.distribution==="developer-id")throw new Error(reason);await log.warn(`${reason} This development build has no updater.`);updater=false}}const key=hostKey(entry,root,webkit,updater);const hostDirectory=storagePath(`framework/desktop/host/${key}`);const host=join(hostDirectory,"craft-native-macos");if(!existsSync(host)){const parts=[webkit&&"WebKit",updater&&"the updater"].filter(Boolean);await log.info(`Building the AppKit host${parts.length?` with ${parts.join(" and ")}`:""} (first build for this Craft; the toolchain installs through Pantry)`);const builder=await import(entry);mkdirSync(hostDirectory,{recursive:true});await builder.buildMacOSNative({outdir:hostDirectory,nativeBundle,...webkit?{webkit:true}:{},...updater?{updater:true}:{}})}return{root,output,nativeBundle,host,hostKey:key,updater}}export function macosAgentEntry(root,config){if(!config.agent)return;if(config.agent.entry){const entry=resolve(root,config.agent.entry);if(!existsSync(entry))throw new Error(`macos.agent.entry does not exist: ${entry}`);return entry}const conventional=join(root,"app/Desktop/Agent.ts");return existsSync(conventional)?conventional:undefined}function agentResources(config,root){const resources=config.agent?.resources;return resources&&Object.keys(resources).length?{resources:Object.fromEntries(Object.entries(resources).map(([name,path])=>[name,resolve(root,path)]))}:{}}export function macosAgentDevManifest(config,prepared){return{appName:config.appName,bundleId:config.bundleId,version:config.version,host:prepared.host,nativeBundle:prepared.nativeBundle,hostArguments:agentHostArguments(config),...config.agent?.port?{port:config.agent.port}:{},...config.agent?.staticDir?{staticDir:resolve(prepared.root,config.agent.staticDir)}:{},...agentResources(config,prepared.root),projectRoot:prepared.root,appRoutes:config.agent?.appRoutes!==false}}export async function macosAgentRouteFiles(root){const manifest=join(root,"app/Routes.ts");const loaded=existsSync(manifest)?(await import(pathToFileURL(manifest).href)).default:undefined;const registry=loaded&&typeof loaded==="object"&&Object.keys(loaded).length?loaded:{api:"api"};const files=[];for(const[key,definition]of Object.entries(registry)){const config=typeof definition==="string"?{path:definition}:definition;const file=[".ts",".js"].map((extension)=>join(root,"routes",`${config.path}${extension}`)).find((candidate)=>existsSync(candidate));if(!file)continue;const prefix=config.prefix!==undefined?config.prefix?config.prefix.startsWith("/")?config.prefix:`/${config.prefix}`:undefined:key==="web"?undefined:`/${key}`;const middleware=config.middleware===undefined?[]:Array.isArray(config.middleware)?config.middleware:[config.middleware];files.push({file,...prefix?{prefix}:{},...middleware.length?{middleware}:{}})}return files}export function macosAgentActionFiles(root,sources){const actions={};for(const source of sources){if(!existsSync(source))continue;for(const match of readFileSync(source,"utf8").matchAll(/['"`](Actions\/[\w/-]+?)(?:\.ts)?['"`]/g)){const name=match[1];if(actions[name])continue;const file=[join(root,"app",`${name}.ts`),join(root,"storage/framework/defaults/app",`${name}.ts`)].find((candidate)=>existsSync(candidate));if(file)actions[name]=file}}return actions}export async function prepareMacosAgent(config,prepared,_distribution){if(!config.agent)throw new Error("config/desktop.ts has no macos.agent");const work=join(prepared.output,".build");const entry=join(work,"agent-entry.ts");const routes=config.agent.appRoutes===false?[]:await macosAgentRouteFiles(prepared.root);const agentEntry=macosAgentEntry(prepared.root,config);const actions=macosAgentActionFiles(prepared.root,[...routes.map((route)=>route.file),...agentEntry?[agentEntry]:[]]);writeFileSync(entry,renderAgentEntry({agentEntry,routes,actions}));const launcher=join(work,`${config.executable}-agent`);const compile=Bun.spawnSync(["bun",...desktopLauncherCompileArgs({entry,outfile:launcher})],{cwd:prepared.root,stdout:"pipe",stderr:"pipe"});if(compile.exitCode!==0)throw new Error(`Compiling the agent launcher failed:
3
+ `)}`);if(process.platform!=="darwin")throw new Error("The native macOS app builds on macOS");const output=macosOutputDirectory(root,config);const work=join(output,".build");mkdirSync(work,{recursive:true});const screens=Object.fromEntries(Object.entries(macosScreens(config)).map(([name,file])=>[name,join(root,file)]));for(const[name,file]of Object.entries(screens))if(!existsSync(file))throw new Error(`macos.nativeScreens: screen "${name}" is ${file}, which does not exist`);const{compileNativeBundle}=await(process.env.STX_NATIVE_SRC?import(pathToFileURL(process.env.STX_NATIVE_SRC).href):import("@stacksjs/stx/native"));const app=config.nativeApp?join(root,config.nativeApp):undefined;const compiled=await compileNativeBundle({screens,initialScreen:config.initialScreen,minify:true,outFile:join(work,"native-screen.js"),root,...app?{app}:{},...config.shareStorage&&Object.keys(config.shareStorage).length?{shareStorage:{...config.shareStorage}}:{}});const problems=(compiled.diagnostics??[]).filter((item)=>item.message!=="dropped-subtree: script");for(const item of problems)await log.warn(`${item.file?`${item.file}: `:""}${item.message}`);if(problems.some((item)=>item.level==="error"))throw new Error("The native screens did not compile");const nativeBundle=compiled.outFile??join(work,"native-screen.js");const entry=craftMacosEntry(root);const webkit=config.webkit===true;if(webkit){const file=entryFile(entry,root);if(!file||!existsSync(file)||!craftSupportsWebkit(readFileSync(file,"utf8")))throw new Error(`macos.webkit needs a Craft whose buildMacOSNative links WebKit, and ${file??entry} does not. Upgrade craft-native, or point CRAFT_MACOS_SRC at a Craft checkout that has it.`)}let updater=macosSelfUpdates(config,options.distribution);if(updater){const file=entryFile(entry,root);if(!file||!existsSync(file)||!craftSupportsUpdater(readFileSync(file,"utf8"))){const reason=`macos.updates needs a Craft whose buildMacOSNative compiles the updater, and ${file??entry} does not. Upgrade craft-native, or point CRAFT_MACOS_SRC at a Craft checkout that has it.`;if(options.distribution==="developer-id")throw new Error(reason);await log.warn(`${reason} This development build has no updater.`);updater=false}}const key=hostKey(entry,root,webkit,updater);const hostDirectory=storagePath(`framework/desktop/host/${key}`);const host=join(hostDirectory,"craft-native-macos");if(!existsSync(host)){const parts=[webkit&&"WebKit",updater&&"the updater"].filter(Boolean);await log.info(`Building the AppKit host${parts.length?` with ${parts.join(" and ")}`:""} (first build for this Craft; the toolchain installs through Pantry)`);const builder=await import(entry);mkdirSync(hostDirectory,{recursive:true});await builder.buildMacOSNative({outdir:hostDirectory,nativeBundle,...webkit?{webkit:true}:{},...updater?{updater:true}:{}})}return{root,output,nativeBundle,host,hostKey:key,updater}}export function macosAgentEntry(root,config){if(!config.agent)return;if(config.agent.entry){const entry=resolve(root,config.agent.entry);if(!existsSync(entry))throw new Error(`macos.agent.entry does not exist: ${entry}`);return entry}const conventional=join(root,"app/Desktop/Agent.ts");return existsSync(conventional)?conventional:undefined}function agentResources(config,root){const resources=config.agent?.resources;return resources&&Object.keys(resources).length?{resources:Object.fromEntries(Object.entries(resources).map(([name,path])=>[name,resolve(root,path)]))}:{}}export function macosAgentDevManifest(config,prepared){return{appName:config.appName,bundleId:config.bundleId,version:config.version,host:prepared.host,nativeBundle:prepared.nativeBundle,hostArguments:agentHostArguments(config),...config.agent?.port?{port:config.agent.port}:{},...config.agent?.staticDir?{staticDir:resolve(prepared.root,config.agent.staticDir)}:{},...agentResources(config,prepared.root),projectRoot:prepared.root,appRoutes:config.agent?.appRoutes!==false}}export async function macosAgentRouteFiles(root){const manifest=join(root,"app/Routes.ts");const loaded=existsSync(manifest)?(await import(pathToFileURL(manifest).href)).default:undefined;const registry=loaded&&typeof loaded==="object"&&Object.keys(loaded).length?loaded:{api:"api"};const files=[];for(const[key,definition]of Object.entries(registry)){const config=typeof definition==="string"?{path:definition}:definition;const file=[".ts",".js"].map((extension)=>join(root,"routes",`${config.path}${extension}`)).find((candidate)=>existsSync(candidate));if(!file)continue;const prefix=config.prefix!==undefined?config.prefix?config.prefix.startsWith("/")?config.prefix:`/${config.prefix}`:undefined:key==="web"?undefined:`/${key}`;const middleware=config.middleware===undefined?[]:Array.isArray(config.middleware)?config.middleware:[config.middleware];files.push({file,...prefix?{prefix}:{},...middleware.length?{middleware}:{}})}return files}export function macosAgentActionFiles(root,sources){const actions={};for(const source of sources){if(!existsSync(source))continue;for(const match of readFileSync(source,"utf8").matchAll(/['"`](Actions\/[\w/-]+?)(?:\.ts)?['"`]/g)){const name=match[1];if(actions[name])continue;const file=[join(root,"app",`${name}.ts`),join(root,"storage/framework/defaults/app",`${name}.ts`)].find((candidate)=>existsSync(candidate));if(file)actions[name]=file}}return actions}export function macosAgentMiddlewareFiles(root){const middleware={};for(const dir of[join(root,"storage/framework/defaults/app/Middleware"),join(root,"app/Middleware")]){if(!existsSync(dir))continue;for(const file of readdirSync(dir)){if(!file.endsWith(".ts")||file.endsWith(".d.ts")||file.endsWith(".test.ts"))continue;middleware[file.slice(0,-3)]=join(dir,file)}}return middleware}export async function prepareMacosAgent(config,prepared,_distribution){if(!config.agent)throw new Error("config/desktop.ts has no macos.agent");const work=join(prepared.output,".build");const entry=join(work,"agent-entry.ts");const routes=config.agent.appRoutes===false?[]:await macosAgentRouteFiles(prepared.root);const agentEntry=macosAgentEntry(prepared.root,config);const actions=macosAgentActionFiles(prepared.root,[...routes.map((route)=>route.file),...agentEntry?[agentEntry]:[]]);const middleware=config.agent.appRoutes===false?{}:macosAgentMiddlewareFiles(prepared.root);writeFileSync(entry,renderAgentEntry({agentEntry,routes,actions,middleware}));const launcher=join(work,`${config.executable}-agent`);const compile=Bun.spawnSync(["bun",...desktopLauncherCompileArgs({entry,outfile:launcher})],{cwd:prepared.root,stdout:"pipe",stderr:"pipe"});if(compile.exitCode!==0)throw new Error(`Compiling the agent launcher failed:
4
4
  ${compile.stderr.toString().trim()||compile.stdout.toString().trim()}`);return{launcher,manifest:{appName:config.appName,bundleId:config.bundleId,version:config.version,hostArguments:agentHostArguments(config),...config.agent.port?{port:config.agent.port}:{},...config.agent.staticDir?{staticDir:resolve(prepared.root,config.agent.staticDir)}:{},...agentResources(config,prepared.root),appRoutes:false}}}export function macosAgentDevFiles(prepared){const work=join(prepared.output,".build");return{entry:join(work,"agent-entry.ts"),manifest:join(work,AGENT_MANIFEST)}}
@@ -1,5 +1,14 @@
1
1
  import type { DevOptions } from '@stacksjs/types';
2
2
  export declare function runDevServer(options: DevOptions): Promise<void>;
3
+ /**
4
+ * Start the frontend dev server, and fail when it does not start.
5
+ *
6
+ * The views entry is imported in this process, so `runAction` reports a module
7
+ * that could not load (an STX older than the framework expects, say) as an
8
+ * `err` result. That result used to be dropped here: `buddy dev:frontend`
9
+ * printed nothing, exited 0 and left no server, and `buddy dev` announced a
10
+ * frontend URL that never answered.
11
+ */
3
12
  export declare function runFrontendDevServer(options: DevOptions): Promise<void>;
4
13
  export declare function runBackendDevServer(options: DevOptions): Promise<void>;
5
14
  export declare function runApiDevServer(options: DevOptions): Promise<void>;
package/dist/dev/index.js CHANGED
@@ -1 +1 @@
1
- import{Action}from"@stacksjs/enums";import{runAction}from"../helpers";export async function runDevServer(options){await runAction(Action.Dev,options)}export async function runFrontendDevServer(options){await runAction(Action.Dev,options)}export async function runBackendDevServer(options){await runApiDevServer(options)}export async function runApiDevServer(options){await runAction(Action.DevApi,options)}export async function runComponentsDevServer(options){await runAction(Action.DevComponents,options)}export async function runDashboardDevServer(options){await runAction(Action.DevDashboard,options)}export async function runSystemTrayDevServer(options){await runAction(Action.DevSystemTray,options)}export async function runDesktopDevServer(options){await runAction(Action.DevDesktop,options)}export async function runDocsDevServer(options){await runAction(Action.DevDocs,options)}
1
+ import{Action}from"@stacksjs/enums";import{runAction}from"../helpers";export async function runDevServer(options){await runAction(Action.Dev,options)}export async function runFrontendDevServer(options){const result=await runAction(Action.Dev,options);if(result.isErr)throw result.error}export async function runBackendDevServer(options){await runApiDevServer(options)}export async function runApiDevServer(options){await runAction(Action.DevApi,options)}export async function runComponentsDevServer(options){await runAction(Action.DevComponents,options)}export async function runDashboardDevServer(options){await runAction(Action.DevDashboard,options)}export async function runSystemTrayDevServer(options){await runAction(Action.DevSystemTray,options)}export async function runDesktopDevServer(options){await runAction(Action.DevDesktop,options)}export async function runDocsDevServer(options){await runAction(Action.DevDocs,options)}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type { GitHubReleaseResult, PublishGitHubReleaseOptions } from './github-release';
2
+ export type { ReviewOsWorkflowOptions, ReviewOsWorkflowRun, ReviewOsWorkflowArtifact } from './reviewos-workflows';
2
3
  export type { ReviewOsEvidencePlan } from './reviewos-evidence';
3
4
  export type { ReleaseEvidenceOptions, ReleaseEvidencePlan, ReleaseEvidenceReceipt, ReleaseSource } from './release-evidence';
4
5
  export type { PublicationChannel } from './publication-preflight';
@@ -42,6 +43,7 @@ export { formatProject, lintFix, lintProject } from './lint/lint';
42
43
  // pushed tag gets, and the Pantry-managed tools behind `build:ios`.
43
44
  export { describeGitHubRelease, parseGitHubRemote, publishGitHubRelease } from './github-release';
44
45
  export { validateReleaseEvidencePlan, verifyReleaseEvidence } from './release-evidence';
46
+ export { reviewOsWorkflows } from './reviewos-workflows';
45
47
  export { evaluateReviewOsEvidence, inspectReviewOsEvidence } from './reviewos-evidence';
46
48
  export { assertPublicationAllowed, PUBLICATION_CHECK_SCRIPT, publicationChannels } from './publication-preflight';
47
49
  export { DEFAULT_IOS_DEPENDENCIES, IosToolchainError, loadIosDependencies, pantryExecutable, pantryInstallArgs, resolveXcodegen, XCODE_NOTE, xcodeDeveloperDir } from './build/ios-toolchain';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{setActionRunner}from"@stacksjs/action-runner";import{runAction}from"./helpers";setActionRunner((action,options)=>runAction(action,options));export*from"./action";export{add as runAdd}from"./add";export{BlogAdminError,deleteBlogPost,getBlogPost,listBlogPosts,saveBlogPost,slugify as blogSlugify}from"./blog-admin";export{commit as runCommit}from"./commit";export*from"./dev";export*from"./generate";export*from"./helpers";export*from"./library";export{formatProject,lintFix,lintProject}from"./lint/lint";export{describeGitHubRelease,parseGitHubRemote,publishGitHubRelease}from"./github-release";export{validateReleaseEvidencePlan,verifyReleaseEvidence}from"./release-evidence";export{evaluateReviewOsEvidence,inspectReviewOsEvidence}from"./reviewos-evidence";export{assertPublicationAllowed,PUBLICATION_CHECK_SCRIPT,publicationChannels}from"./publication-preflight";export{DEFAULT_IOS_DEPENDENCIES,IosToolchainError,loadIosDependencies,pantryExecutable,pantryInstallArgs,resolveXcodegen,XCODE_NOTE,xcodeDeveloperDir}from"./build/ios-toolchain";export{craftSupportsUpdater,craftSupportsWebkit,macosAgentActionFiles,macosAgentDevFiles,macosAgentDevManifest,macosAgentEntry,macosAgentRouteFiles,prepareMacosAgent,prepareMacosNative}from"./build/macos-native";export{DEFAULT_STX_LINT_CONFIG,loadStxLintConfig,runStxLint}from"./lint/stx-gate";export{measureDefaultsDrift,summarizeStructureChanges}from"./upgrade/package-project";export{describeDanglingRouteActions,findDanglingRouteActions}from"./upgrade/route-actions";export*from"./setup";export{createComponent,createDatabase,createFactory,createFunction,createLanguage,createMiddleware,createMigration,createModel,createMail,createNotification,createPage,isDryRunActive,makeAction,makeCertificate,makeComponent,makeDatabase,makeFunction,makeLanguage,makeMail,makeNotification,makePage,makeQueueTable,makeStack,make as runMake,setDryRun}from"./make";export{discoverPackages,ensureDiscoveredPackages}from"./discover-packages";export{parseFields,scaffoldCrud}from"./scaffold-crud";export{installStack,uninstallStack,listStacks}from"./stacks";export{makeJob}from"./make-job";export{makeCommand}from"./make-command";export{makePolicy}from"./make-policy";export{makeResource}from"./make-resource";export{resolveStxSource}from"./stx-source";
1
+ import{setActionRunner}from"@stacksjs/action-runner";import{runAction}from"./helpers";setActionRunner((action,options)=>runAction(action,options));export*from"./action";export{add as runAdd}from"./add";export{BlogAdminError,deleteBlogPost,getBlogPost,listBlogPosts,saveBlogPost,slugify as blogSlugify}from"./blog-admin";export{commit as runCommit}from"./commit";export*from"./dev";export*from"./generate";export*from"./helpers";export*from"./library";export{formatProject,lintFix,lintProject}from"./lint/lint";export{describeGitHubRelease,parseGitHubRemote,publishGitHubRelease}from"./github-release";export{validateReleaseEvidencePlan,verifyReleaseEvidence}from"./release-evidence";export{reviewOsWorkflows}from"./reviewos-workflows";export{evaluateReviewOsEvidence,inspectReviewOsEvidence}from"./reviewos-evidence";export{assertPublicationAllowed,PUBLICATION_CHECK_SCRIPT,publicationChannels}from"./publication-preflight";export{DEFAULT_IOS_DEPENDENCIES,IosToolchainError,loadIosDependencies,pantryExecutable,pantryInstallArgs,resolveXcodegen,XCODE_NOTE,xcodeDeveloperDir}from"./build/ios-toolchain";export{craftSupportsUpdater,craftSupportsWebkit,macosAgentActionFiles,macosAgentDevFiles,macosAgentDevManifest,macosAgentEntry,macosAgentRouteFiles,prepareMacosAgent,prepareMacosNative}from"./build/macos-native";export{DEFAULT_STX_LINT_CONFIG,loadStxLintConfig,runStxLint}from"./lint/stx-gate";export{measureDefaultsDrift,summarizeStructureChanges}from"./upgrade/package-project";export{describeDanglingRouteActions,findDanglingRouteActions}from"./upgrade/route-actions";export*from"./setup";export{createComponent,createDatabase,createFactory,createFunction,createLanguage,createMiddleware,createMigration,createModel,createMail,createNotification,createPage,isDryRunActive,makeAction,makeCertificate,makeComponent,makeDatabase,makeFunction,makeLanguage,makeMail,makeNotification,makePage,makeQueueTable,makeStack,make as runMake,setDryRun}from"./make";export{discoverPackages,ensureDiscoveredPackages}from"./discover-packages";export{parseFields,scaffoldCrud}from"./scaffold-crud";export{installStack,uninstallStack,listStacks}from"./stacks";export{makeJob}from"./make-job";export{makeCommand}from"./make-command";export{makePolicy}from"./make-policy";export{makeResource}from"./make-resource";export{resolveStxSource}from"./stx-source";
@@ -1,9 +1,11 @@
1
1
  /** Verify execution, rather than treating a completed/cancelled run as proof. */
2
2
  export declare function evaluateReviewOsEvidence(plan: ReviewOsEvidencePlan, value: unknown): Decision;
3
- /** Read public execution metadata through the forge API; no runner or admin credential. */
3
+ /** Read execution metadata through the forge API; never a runner or controller credential. */
4
4
  export declare function inspectReviewOsEvidence(plan: ReviewOsEvidencePlan, options?: {
5
5
  fetch?: typeof fetch
6
6
  signal?: AbortSignal
7
+
8
+ token?: string
7
9
  }): Promise<Decision>;
8
10
  export declare interface ReviewOsEvidencePlan {
9
11
  origin: string
@@ -1 +1 @@
1
- function blocked(reason){throw new Error(`ReviewOS evidence blocked: ${reason}`)}function validate(plan){const origin=new URL(plan.origin);if(origin.protocol!=="https:"||origin.username||origin.password||origin.pathname!=="/"||origin.search||origin.hash||!/^[\w.-]+$/.test(plan.owner)||!/^[\w.-]+$/.test(plan.repository)||!/^[a-f0-9]{40}$/.test(plan.commit)||!/^[a-f0-9]{64}$/.test(plan.workflowDigest)||!/^\.reviewos\/workflows\/[\w.-]+\.ya?ml$/.test(plan.workflow)||!plan.job||!plan.labels.length||!plan.steps.length||[...plan.labels,...plan.steps].some((value)=>typeof value!=="string"||!value)||new Set(plan.steps).size!==plan.steps.length)blocked("Expected an HTTPS forge, exact source and workflow identities, job, labels and steps");return origin}export function evaluateReviewOsEvidence(plan,value){const origin=validate(plan);const run=value?.workflow_run;if(!run||!Number.isSafeInteger(run.number)||run.number<=0||run.head_sha!==plan.commit||run.trusted!==true||run.ref!=="refs/heads/main"||!["push","workflow_dispatch"].includes(run.event)||run.workflow?.path!==plan.workflow||run.workflow?.owner_defined!==false||run.version?.path!==plan.workflow||run.version?.digest!==plan.workflowDigest)blocked("The run does not identify the trusted main source and committed workflow");if(["queued","running","waiting","paused"].includes(run.state))return{state:"pending"};if(run.state!=="succeeded")blocked(`Run ${run.number} concluded ${String(run.state)}`);if(!Array.isArray(run.jobs))blocked("The run has no job evidence");const jobs=run.jobs.filter((job)=>job.job_id===plan.job);const job=jobs[0];if(jobs.length!==1||job.state!=="succeeded"||!job.runner||!job.started_at||!job.finished_at||job.resume_from_step!==null||!Array.isArray(job.runs_on)||plan.labels.some((label)=>!job.runs_on.includes(label))||!Array.isArray(job.steps))blocked("The required job did not execute fully on the declared runner");for(const name of plan.steps){const steps=job.steps.filter((step)=>step.name===name);const step=steps[0];if(steps.length!==1||step.state!=="succeeded"||step.exit_code!==0||!step.started_at||!step.finished_at||step.reused_from_attempt!=null)blocked(`Required step did not execute successfully: ${name}`)}return{state:"accepted",number:run.number,url:new URL(`/${plan.owner}/${plan.repository}/run/${run.number}`,origin).href}}export async function inspectReviewOsEvidence(plan,options={}){const origin=validate(plan);const request=options.fetch??fetch;async function read(path,values){const url=new URL(`/api/repos/${path}`,origin);for(const[name,value]of Object.entries({owner:plan.owner,repo:plan.repository,...values}))url.searchParams.set(name,value);const response=await request(url.href,{redirect:"error",headers:{accept:"application/json"},signal:options.signal?AbortSignal.any([options.signal,AbortSignal.timeout(30000)]):AbortSignal.timeout(30000)});if(!response.ok)blocked(`Metadata API returned HTTP ${response.status}`);if(!response.body)blocked("Metadata API returned no body");const reader=response.body.getReader();const chunks=[];let size=0;try{while(true){const part=await reader.read();if(part.done)break;size+=part.value.byteLength;if(size>1048576)blocked("Metadata exceeds its byte budget");chunks.push(part.value)}return JSON.parse(Buffer.concat(chunks).toString("utf8"))}finally{await reader.cancel().catch(()=>{});reader.releaseLock()}}async function pages(path,field,values){const rows=[];const cursors=new Set;let cursor="";for(let page=0;page<10;page++){const data=await read(path,{...values,per_page:"100",...cursor?{cursor}:{}});if(!Array.isArray(data[field]))blocked("Metadata API returned an invalid collection");rows.push(...data[field]);if(data.next===null)return rows;if(typeof data.next!=="string"||!data.next||cursors.has(data.next))blocked("Invalid metadata pagination");cursors.add(data.next);cursor=data.next}return blocked("Metadata exceeds its page budget")}const workflows=(await pages("workflows","workflows",{})).filter((row)=>row.path===plan.workflow);if(!workflows.length)return{state:"pending"};if(workflows.length!==1||!Number.isSafeInteger(workflows[0].id)||workflows[0].id<=0)blocked("Workflow identity is ambiguous");const runs=await pages("workflow-runs","workflow_runs",{workflow:String(workflows[0].id),sha:plan.commit,branch:"main"});if(runs.some((row)=>row.head_sha!==plan.commit||!Number.isSafeInteger(row.number)||row.number<=0))blocked("Run collection has an invalid source identity");const newest=runs.sort((a,b)=>b.number-a.number)[0];if(!newest)return{state:"pending"};const detail=await read("workflow-runs/show",{number:String(newest.number)});if(detail?.workflow_run?.number!==newest.number)blocked("Run detail does not match the selected run");return evaluateReviewOsEvidence(plan,detail)}
1
+ import{reviewOsWorkflows}from"./reviewos-workflows.js";function blocked(reason){throw new Error(`ReviewOS evidence blocked: ${reason}`)}function validate(plan){const origin=new URL(plan.origin);if(origin.protocol!=="https:"||origin.username||origin.password||origin.pathname!=="/"||origin.search||origin.hash||!/^[\w.-]+$/.test(plan.owner)||!/^[\w.-]+$/.test(plan.repository)||!/^[a-f0-9]{40}$/.test(plan.commit)||!/^[a-f0-9]{64}$/.test(plan.workflowDigest)||!/^\.reviewos\/workflows\/[\w.-]+\.ya?ml$/.test(plan.workflow)||!plan.job||!plan.labels.length||!plan.steps.length||[...plan.labels,...plan.steps].some((value)=>typeof value!=="string"||!value)||new Set(plan.steps).size!==plan.steps.length)blocked("Expected an HTTPS forge, exact source and workflow identities, job, labels and steps");return origin}export function evaluateReviewOsEvidence(plan,value){const origin=validate(plan);const run=value?.workflow_run;if(!run||!Number.isSafeInteger(run.number)||run.number<=0||run.head_sha!==plan.commit||run.trusted!==true||run.ref!=="refs/heads/main"||!["push","workflow_dispatch"].includes(run.event)||run.workflow?.path!==plan.workflow||run.workflow?.owner_defined!==false||run.version?.path!==plan.workflow||run.version?.digest!==plan.workflowDigest)blocked("The run does not identify the trusted main source and committed workflow");if(["queued","running","waiting","paused"].includes(run.state))return{state:"pending"};if(run.state!=="succeeded")blocked(`Run ${run.number} concluded ${String(run.state)}`);if(!Array.isArray(run.jobs))blocked("The run has no job evidence");const jobs=run.jobs.filter((job)=>job.job_id===plan.job);const job=jobs[0];if(jobs.length!==1||job.state!=="succeeded"||!job.runner||!job.started_at||!job.finished_at||job.resume_from_step!==null||!Array.isArray(job.runs_on)||plan.labels.some((label)=>!job.runs_on.includes(label))||!Array.isArray(job.steps))blocked("The required job did not execute fully on the declared runner");for(const name of plan.steps){const steps=job.steps.filter((step)=>step.name===name);const step=steps[0];if(steps.length!==1||step.state!=="succeeded"||step.exit_code!==0||!step.started_at||!step.finished_at||step.reused_from_attempt!=null)blocked(`Required step did not execute successfully: ${name}`)}return{state:"accepted",number:run.number,url:new URL(`/${plan.owner}/${plan.repository}/run/${run.number}`,origin).href}}export async function inspectReviewOsEvidence(plan,options={}){const origin=validate(plan);const client=reviewOsWorkflows({origin:origin.origin,repository:`${plan.owner}/${plan.repository}`,...options});try{const runs=await client.runs(plan.workflow,{sha:plan.commit,branch:"main"});const newest=runs.sort((a,b)=>b.number-a.number)[0];if(!newest)return{state:"pending"};return evaluateReviewOsEvidence(plan,{workflow_run:await client.run(newest.number)})}catch(error){return blocked(error instanceof Error?error.message:"Could not inspect workflow execution")}}
@@ -0,0 +1,30 @@
1
+ /** Public, bounded workflow metadata and dispatch. No controller database or runner credential. */
2
+ export declare function reviewOsWorkflows(options: ReviewOsWorkflowOptions): {
3
+ runs: (workflow: string, filter?: { branch?: string, sha?: string }) => Promise<ReviewOsWorkflowRun[]>;
4
+ run: (number: number) => Promise<ReviewOsWorkflowRun>;
5
+ dispatch: (workflow: string, ref: string, inputs?: Record<string, string | number | boolean>) => Promise<{ number: number, state: string }>;
6
+ artifacts: (number: number) => Promise<ReviewOsWorkflowArtifact[]>
7
+ };
8
+ export declare interface ReviewOsWorkflowRun {
9
+ number: number
10
+ state: string
11
+ head_sha: string
12
+ ref?: string
13
+ trusted?: boolean
14
+ jobs?: Array<Record<string, unknown>>
15
+ [key: string]: unknown
16
+ }
17
+ export declare interface ReviewOsWorkflowArtifact {
18
+ id: number
19
+ name: string
20
+ digest: string
21
+ size_bytes: number
22
+ expires_at?: string | null
23
+ }
24
+ export declare interface ReviewOsWorkflowOptions {
25
+ origin: string
26
+ repository: string
27
+ token?: string
28
+ fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>
29
+ signal?: AbortSignal
30
+ }
@@ -0,0 +1 @@
1
+ import{boundedBody}from"./library/archive.js";const states=new Set(["queued","running","waiting","paused","succeeded","failed","cancelled","skipped"]);function fail(reason){throw new Error(`ReviewOS workflow request blocked: ${reason}`)}function positive(value){return Number.isSafeInteger(value)&&Number(value)>0}function workflowPath(value){const path=value.startsWith(".reviewos/workflows/")?value:`.reviewos/workflows/${value}`;if(!/^\.reviewos\/workflows\/[\w.-]+\.ya?ml$/.test(path))fail("Expected a committed workflow file");return path}function summary(value){if(!value||!positive(value.number)||!states.has(value.state)||!/^[a-f0-9]{40}$/.test(value.head_sha))fail("Invalid run source identity");return value}export function reviewOsWorkflows(options){const origin=new URL(options.origin);if(origin.protocol!=="https:"||origin.username||origin.password||origin.pathname!=="/"||origin.search||origin.hash||!/^[\w.-]+\/[\w.-]+$/.test(options.repository)||options.repository.split("/").some((part)=>part==="."||part===".."))fail("Expected a canonical HTTPS instance and owner/repository");const[owner,repo]=options.repository.split("/");const request=options.fetch??fetch;async function read(path,query={},body){const url=new URL(`/api/repos/${path}`,origin);for(const[key,value]of Object.entries({owner,repo,...query}))url.searchParams.set(key,value);const response=await request(url.href,{method:body===undefined?"GET":"POST",redirect:"error",headers:{accept:"application/json",...options.token?{authorization:`Bearer ${options.token}`}:{},...body===undefined?{}:{"content-type":"application/json"}},signal:options.signal?AbortSignal.any([options.signal,AbortSignal.timeout(30000)]):AbortSignal.timeout(30000),...body===undefined?{}:{body:JSON.stringify(body)}});if(!response.ok){await response.body?.cancel();fail(`Metadata API returned HTTP ${response.status}`)}const bytes=await boundedBody(response,1048576);try{return JSON.parse(Buffer.from(bytes).toString("utf8"))}catch{return fail("Metadata was not JSON")}}async function pages(path,field,query={}){const rows=[],cursors=new Set;let cursor="";for(let page=0;page<10;page++){const data=await read(path,{...query,per_page:"100",...cursor?{cursor}:{}});if(!Array.isArray(data[field]))fail("Invalid metadata collection");rows.push(...data[field]);if(data.next===null)return rows;if(typeof data.next!=="string"||!data.next||cursors.has(data.next))fail("Invalid metadata pagination");cursors.add(data.next);cursor=data.next}return fail("Metadata pagination exceeds its budget")}return{async runs(workflow,filter={}){const path=workflowPath(workflow);const workflows=(await pages("workflows","workflows")).filter((row)=>row.path===path&&row.owner_defined!==true);if(!workflows.length)return[];if(workflows.length!==1||!positive(workflows[0].id))fail("Ambiguous workflow identity");if(filter.sha!==undefined&&!/^[a-f0-9]{40}$/.test(filter.sha))fail("Expected an exact source commit");const rows=(await pages("workflow-runs","workflow_runs",{workflow:String(workflows[0].id),...filter.branch?{branch:filter.branch}:{},...filter.sha?{sha:filter.sha}:{}})).map(summary);if(filter.sha&&rows.some((row)=>row.head_sha!==filter.sha))fail("Run collection changed source identity");if(new Set(rows.map((row)=>row.number)).size!==rows.length)fail("Duplicate run identity");return rows},async run(number){if(!positive(number))fail("Expected a run number");const run=summary((await read("workflow-runs/show",{number:String(number)})).workflow_run);if(run.number!==number||typeof run.trusted!=="boolean"||typeof run.ref!=="string"||!Array.isArray(run.jobs))fail("Run detail changed identity or omitted execution metadata");return run},async dispatch(workflow,ref,inputs={}){const path=workflowPath(workflow);if(!inputs||typeof inputs!=="object"||Array.isArray(inputs)||Object.entries(inputs).some(([key,value])=>!/^[\w.-]+$/.test(key)||!["string","number","boolean"].includes(typeof value)||typeof value==="number"&&!Number.isFinite(value)))fail("Expected scalar workflow input values");if(!ref||/[\r\n\x00]/.test(ref))fail("Expected a source ref");const run=(await read("workflows/dispatch",{},{owner,repo,workflow:path,ref,inputs})).workflow_run;if(!run||!positive(run.number)||!states.has(run.state))fail("Dispatch returned no run identity");return{number:run.number,state:run.state}},async artifacts(number){if(!positive(number))fail("Expected a run number");const rows=(await read("workflow-runs/artifacts",{number:String(number)})).artifacts;if(!Array.isArray(rows)||rows.some((row)=>!positive(row.id)||typeof row.name!=="string"||!row.name||!/^[a-f0-9]{64}$/.test(row.digest)||!Number.isSafeInteger(row.size_bytes)||row.size_bytes<0))fail("Invalid artifact identities");return rows}}}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/actions",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.599",
5
+ "version": "0.75.602",
6
6
  "description": "The Stacks actions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -68,55 +68,55 @@
68
68
  "dependencies": {
69
69
  "@babel/parser": "^8.1.2",
70
70
  "@babel/types": "^8.1.2",
71
- "@stacksjs/action-runner": "0.75.599",
72
- "@stacksjs/ai": "0.75.599",
73
- "@stacksjs/analytics": "0.75.599",
74
- "@stacksjs/api": "0.75.599",
75
- "@stacksjs/auth": "0.75.599",
76
- "@stacksjs/build": "0.75.599",
77
- "@stacksjs/bumpx": "^0.2.26",
71
+ "@stacksjs/action-runner": "0.75.602",
72
+ "@stacksjs/ai": "0.75.602",
73
+ "@stacksjs/analytics": "0.75.602",
74
+ "@stacksjs/api": "0.75.602",
75
+ "@stacksjs/auth": "0.75.602",
76
+ "@stacksjs/build": "0.75.602",
77
+ "@stacksjs/bumpx": "^0.2.32",
78
78
  "@stacksjs/bunpress": "^0.2.15",
79
- "@stacksjs/cli": "0.75.599",
80
- "@stacksjs/cloud": "0.75.599",
81
- "@stacksjs/cms": "0.75.599",
79
+ "@stacksjs/cli": "0.75.602",
80
+ "@stacksjs/cloud": "0.75.602",
81
+ "@stacksjs/cms": "0.75.602",
82
82
  "@stacksjs/components": "^0.2.889",
83
- "@stacksjs/config": "0.75.599",
84
- "@stacksjs/database": "0.75.599",
85
- "@stacksjs/desktop-build": "0.75.599",
86
- "@stacksjs/dns": "0.75.599",
87
- "@stacksjs/docs": "0.75.599",
88
- "@stacksjs/enums": "0.75.599",
89
- "@stacksjs/env": "0.75.599",
90
- "@stacksjs/error-handling": "0.75.599",
91
- "@stacksjs/github": "0.75.599",
83
+ "@stacksjs/config": "0.75.602",
84
+ "@stacksjs/database": "0.75.602",
85
+ "@stacksjs/desktop-build": "0.75.602",
86
+ "@stacksjs/dns": "0.75.602",
87
+ "@stacksjs/docs": "0.75.602",
88
+ "@stacksjs/enums": "0.75.602",
89
+ "@stacksjs/env": "0.75.602",
90
+ "@stacksjs/error-handling": "0.75.602",
91
+ "@stacksjs/github": "0.75.602",
92
92
  "@stacksjs/gitit": "^0.2.5",
93
- "@stacksjs/i18n": "0.75.599",
94
- "@stacksjs/image": "0.75.599",
95
- "@stacksjs/logging": "0.75.599",
93
+ "@stacksjs/i18n": "0.75.602",
94
+ "@stacksjs/image": "0.75.602",
95
+ "@stacksjs/logging": "0.75.602",
96
96
  "@stacksjs/logsmith": "^0.2.11",
97
- "@stacksjs/mobile": "0.75.599",
98
- "@stacksjs/orm": "0.75.599",
99
- "@stacksjs/path": "0.75.599",
100
- "@stacksjs/payments": "0.75.599",
101
- "@stacksjs/queue": "0.75.599",
102
- "@stacksjs/registry": "0.75.599",
103
- "@stacksjs/router": "0.75.599",
97
+ "@stacksjs/mobile": "0.75.602",
98
+ "@stacksjs/orm": "0.75.602",
99
+ "@stacksjs/path": "0.75.602",
100
+ "@stacksjs/payments": "0.75.602",
101
+ "@stacksjs/queue": "0.75.602",
102
+ "@stacksjs/registry": "0.75.602",
103
+ "@stacksjs/router": "0.75.602",
104
104
  "@stacksjs/rpx": "^0.11.54",
105
- "@stacksjs/scheduler": "0.75.599",
106
- "@stacksjs/search-engine": "0.75.599",
107
- "@stacksjs/security": "0.75.599",
108
- "@stacksjs/server": "0.75.599",
109
- "@stacksjs/sites": "0.75.599",
110
- "@stacksjs/storage": "0.75.599",
111
- "@stacksjs/strings": "0.75.599",
105
+ "@stacksjs/scheduler": "0.75.602",
106
+ "@stacksjs/search-engine": "0.75.602",
107
+ "@stacksjs/security": "0.75.602",
108
+ "@stacksjs/server": "0.75.602",
109
+ "@stacksjs/sites": "0.75.602",
110
+ "@stacksjs/storage": "0.75.602",
111
+ "@stacksjs/strings": "0.75.602",
112
112
  "@stacksjs/stx": "^0.2.889",
113
113
  "@stacksjs/tlsx": "^0.13.19",
114
- "@stacksjs/ts-cloud": "^0.16.129",
114
+ "@stacksjs/ts-cloud": "^0.16.135",
115
115
  "@stacksjs/ts-md": "^0.1.1",
116
- "@stacksjs/tunnel": "0.75.599",
117
- "@stacksjs/types": "0.75.599",
118
- "@stacksjs/utils": "0.75.599",
119
- "@stacksjs/whois": "0.75.599",
116
+ "@stacksjs/tunnel": "0.75.602",
117
+ "@stacksjs/types": "0.75.602",
118
+ "@stacksjs/utils": "0.75.602",
119
+ "@stacksjs/whois": "0.75.602",
120
120
  "bun-plugin-stx": "^0.2.889",
121
121
  "pickier": "^0.1.92"
122
122
  },
@@ -129,7 +129,7 @@
129
129
  }
130
130
  },
131
131
  "devDependencies": {
132
- "@stacksjs/validation": "0.75.599",
132
+ "@stacksjs/validation": "0.75.602",
133
133
  "better-dx": "^0.2.39"
134
134
  }
135
135
  }