@automaton-labs/aib 0.0.5 → 0.0.6

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 (38) hide show
  1. package/dist/bin/cli.js +2 -2
  2. package/dist/commands/config-command.js +2 -1
  3. package/dist/commands/config-output.js +10 -8
  4. package/dist/commands/doctor.js +2 -1
  5. package/dist/commands/help-command.js +4 -4
  6. package/dist/commands/inspect-format.js +1 -1
  7. package/dist/commands/quick-read.js +8 -8
  8. package/dist/commands/result-view.js +5 -5
  9. package/dist/commands/session-workspace.js +7 -7
  10. package/dist/config/workspace-root.js +3 -3
  11. package/dist/help/bootstrap.md +4 -7
  12. package/dist/help/docs/help-format.md +4 -7
  13. package/dist/help/dsl/bootstrap.md +4 -7
  14. package/dist/help/dsl/docs/help-format.md +4 -7
  15. package/dist/help/dsl/full.md +4 -7
  16. package/dist/help/dsl/topics/help-format.md +4 -7
  17. package/dist/help/full.md +4 -7
  18. package/dist/help/help-meta.json +5 -5
  19. package/dist/help/json/bootstrap.md +4 -7
  20. package/dist/help/json/docs/help-format.md +4 -7
  21. package/dist/help/json/full.md +4 -7
  22. package/dist/help/json/topics/help-format.md +4 -7
  23. package/dist/help/topics/help-format.md +4 -7
  24. package/dist/managed-host/serve-web-autostart.js +1 -1
  25. package/dist/managed-host/serve-web-host.cjs +193 -79
  26. package/dist/observability/config.js +1 -1
  27. package/dist/payloads/read-stdin-json.js +1 -1
  28. package/dist/runtime/managed-runtime-provisioning.js +1 -1
  29. package/dist/runtime/run-command.js +1 -1
  30. package/dist/session/server.js +7 -5
  31. package/dist/shared/errors.js +14 -13
  32. package/dist/shared/stdin-examples.js +3 -0
  33. package/dist/tracing/trace.js +5 -3
  34. package/extension/vscode-refactor-bridge-extension.vsix +0 -0
  35. package/package.json +1 -1
  36. package/runtimes/launcher/linux-x64/aib +0 -0
  37. package/runtimes/launcher/win-x64/aib.exe +0 -0
  38. package/scripts/provision-runtime.cjs +25 -1
@@ -1,29 +1,30 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CliError=void 0,exports.errorPayload=E;const m=require("./agent-text");class f extends Error{code;details;constructor(n,s,i){super(s),this.code=n,this.details=i}}exports.CliError=f;function p(e){return Array.isArray(e)&&e.every(n=>n!==null&&typeof n=="object"&&typeof n.kind=="string"&&typeof n.description=="string")}function r(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:Array.isArray(e)?e.map(n=>r(n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([n,s])=>[n,r(s)])):String(e)}function A(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e.hints;return p(n)?r(n):null}function _(e){return!!(e&&typeof e=="object"&&Array.isArray(e.issues))}function I(e){return!e||e.length===0?"<root>":e.map(n=>String(n)).join(".")}function N(e){return e.issues.map(n=>({path:I(n.path),message:typeof n.message=="string"?n.message:"Invalid value.",...typeof n.code=="string"?{code:n.code}:{}}))}function E(e){if(e instanceof f){const n={ok:!1,code:e.code,error:e.message,details:e.details?r(e.details):null},s=S(e);s&&(n[m.AGENT_TEXT_FIELD]=s);const i=A(e.details);return i?{...n,hints:i}:n}return _(e)?{ok:!1,code:"INVALID_INPUT",error:"Input JSON does not match the expected command shape.",details:{issues:N(e)}}:{ok:!1,code:"UNEXPECTED_ERROR",error:e instanceof Error?e.message:String(e),details:null}}function S(e){if(e.code==="EMPTY_STDIN")return["DSL payload on stdin","","PowerShell:","@'","<input>","'@ | aib <command> --stdin","","Bash/Zsh:","cat <<'EOF' | aib <command> --stdin","<input>","EOF","","cmd.exe:","type request.dsl | aib <command> --stdin"].join(`
2
- `);if(e.code==="INVALID_STDIN_DSL"){const n=a(e.details),s=c(n.cause);return["invalid DSL stdin",...s?["",s]:[],"","Fix the DSL line and rerun the command."].join(`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CliError=void 0,exports.errorPayload=g;const p=require("./agent-text"),m=require("./stdin-examples");class f extends Error{code;details;constructor(n,i,s){super(i),this.code=n,this.details=s}}exports.CliError=f;function _(e){return Array.isArray(e)&&e.every(n=>n!==null&&typeof n=="object"&&typeof n.kind=="string"&&typeof n.description=="string")}function l(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:Array.isArray(e)?e.map(n=>l(n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([n,i])=>[n,l(i)])):String(e)}function A(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e.hints;return _(n)?l(n):null}function I(e){return!!(e&&typeof e=="object"&&Array.isArray(e.issues))}function N(e){return!e||e.length===0?"<root>":e.map(n=>String(n)).join(".")}function h(e){return e.issues.map(n=>({path:N(n.path),message:typeof n.message=="string"?n.message:"Invalid value.",...typeof n.code=="string"?{code:n.code}:{}}))}function g(e){if(e instanceof f){const n={ok:!1,code:e.code,error:e.message,details:e.details?l(e.details):null},i=S(e);i&&(n[p.AGENT_TEXT_FIELD]=i);const s=A(e.details);return s?{...n,hints:s}:n}return I(e)?{ok:!1,code:"INVALID_INPUT",error:"Input JSON does not match the expected command shape.",details:{issues:h(e)}}:{ok:!1,code:"UNEXPECTED_ERROR",error:e instanceof Error?e.message:String(e),details:null}}function S(e){if(e.code==="EMPTY_STDIN")return["stdin payload is empty","",(0,m.formatStdinExamples)({includeQr:!0})].join(`
2
+ `);if(e.code==="INVALID_STDIN_DSL"){const n=o(e.details),i=c(n.cause);return["invalid DSL stdin",...i?["",i]:[],"","Fix the DSL line and rerun the command."].join(`
3
3
  `)}if(e.code==="INVALID_STDIN_FORMAT")return["invalid stdin format","","Use:","--stdin-format auto","--stdin-format dsl"].join(`
4
4
  `);if(e.code==="INPUT_SOURCE_CONFLICT"||e.code.endsWith("_INPUT_SOURCE_CONFLICT"))return["input source conflict","","Use only one input source:","--stdin","--from <handle-or-file>","--from-json <file>","--from-dsl <file>"].join(`
5
5
  `);if(e.code==="INPUT_FROM_UNSUPPORTED")return["file input is not supported for this command","","Run the command without --from."].join(`
6
6
  `);if(e.code==="INPUT_STDIN_UNSUPPORTED")return["stdin input is not supported for this command","","Run the command without --stdin."].join(`
7
7
  `);if(e.code==="STDIN_DSL_COMMAND_MISMATCH")return["DSL command mismatch","",e.message,"","Run the command that matches the DSL intent, or change the DSL operation."].join(`
8
8
  `);if(e.code==="STDIN_DSL_UNSUPPORTED")return["DSL stdin is not supported for this command","","Use JSON input for this command, or run a DSL-capable command."].join(`
9
- `);if(e.code.startsWith("INVALID_")&&e.code.endsWith("_JSON_FILE")){const n=a(e.details),s=c(n.file);return["input file could not be read",...s?["",`file: ${s}`]:[],"","Check the path or saved input handle."].join(`
10
- `)}if(e.code==="UNKNOWN_COMMAND"){const n=a(e.details),s=Array.isArray(n.availableCommands)?n.availableCommands.filter(o=>typeof o=="string"):[],i=["help","config","sync","inspect","modulePlan","move","rename","imports","session","feedback"],t=s.length>0?i.filter(o=>o==="config"||s.includes(o)):i;return[e.message.replace(/^Unknown command:/,"unknown command:"),...t.length>0?["",`Common commands: ${t.join(", ")}`]:[],"","Run:","aib help"].join(`
9
+ `);if(e.code.startsWith("INVALID_")&&e.code.endsWith("_JSON_FILE")){const n=o(e.details),i=c(n.file);return["input file could not be read",...i?["",`file: ${i}`]:[],"","Check the path or saved input handle."].join(`
10
+ `)}if(e.code==="UNKNOWN_COMMAND"){const n=o(e.details),i=Array.isArray(n.availableCommands)?n.availableCommands.filter(a=>typeof a=="string"):[],s=["help","config","sync","inspect","modulePlan","move","rename","imports","session","feedback"],t=i.length>0?s.filter(a=>a==="config"||i.includes(a)):s;return[e.message.replace(/^Unknown command:/,"unknown command:"),...t.length>0?["",`Common commands: ${t.join(", ")}`]:[],"","Run:","aib help"].join(`
11
11
  `)}if(e.code==="HELP_TOPIC_NOT_FOUND")return e.message;if(e.code==="INVALID_INSPECT_OP")return["invalid inspect operation","","Use: file, imports, exports, members, code, deps, usages, duplicates, graph, tree, cycles","","Example:","aib inspect file src/service.ts"].join(`
12
12
  `);if(e.code==="MODULE_PLAN_SOURCE_REQUIRED")return["modulePlan needs a source file","","DSL:","@source src/large-service.ts","module src/large-service.core.ts: LargeService createLargeService"].join(`
13
13
  `);if(e.code==="MODULE_PLAN_MODULES_REQUIRED")return["modulePlan needs at least one target module","","DSL:","@source src/large-service.ts","module src/large-service.core.ts: LargeService createLargeService"].join(`
14
14
  `);if(e.code==="NORMALIZE_IMPORTS_SCOPE_REQUIRED")return["imports normalize needs a file or directory scope","","DSL:","imports.normalize scope=src/features to=shortestAlias","","CLI:","aib imports normalize preview src/features"].join(`
15
15
  `);if(e.code==="INVALID_NORMALIZE_IMPORTS_MODE")return["imports normalize --to expects relative, alias, or shortestAlias","","Example:","aib imports normalize preview src/features --to shortestAlias"].join(`
16
16
  `);if(e.code==="WORKSPACE_ROOT_NOT_INITIALIZED")return["aib workspace not initialized","","No aib.json was found.","","If you are a user:","ask your agent to set up AIB for this repo:","aib help first-setup","","If you are an agent:","run:","aib help first-setup","","Then follow the setup from the intended repository root."].join(`
17
- `);if(e.code==="EXECUTION_NOT_FOUND"||e.code==="MODULE_PLAN_EXECUTION_NOT_FOUND"||e.code==="REFACTOR_BATCH_EXECUTION_NOT_FOUND"){const n=a(e.details);return[`execution not found: ${c(n.executionId)??"last"}`,"","No execution status exists for this id.","Run a long mutation first, or check the execution id."].join(`
18
- `)}if(e.code==="SESSION_HANDLE_NOT_FOUND"){const n=a(e.details),s=c(n.handle)??"unknown",i=c(n.sessionDir);return[`handle not found: ${s}`,...i?["",`session: ${i}`]:[],"","The artifact may have been cleared or was never saved."].join(`
17
+ `);if(e.code==="CONFIG_UPGRADE_CONFIG_NOT_FOUND")return["aib config upgrade skipped","","There is no aib.json config to upgrade in this directory tree.","","If this is the wrong directory:","go into the repository that already has aib.json, then run:","aib config upgrade","","If this is the repository you want to set up:","ask your agent:","Set up AIB in this repo. Start with `aib help first-setup`."].join(`
18
+ `);if(e.code==="EXECUTION_NOT_FOUND"||e.code==="MODULE_PLAN_EXECUTION_NOT_FOUND"||e.code==="REFACTOR_BATCH_EXECUTION_NOT_FOUND"){const n=o(e.details);return[`execution not found: ${c(n.executionId)??"last"}`,"","No execution status exists for this id.","Run a long mutation first, or check the execution id."].join(`
19
+ `)}if(e.code==="SESSION_HANDLE_NOT_FOUND"||e.code==="SESSION_RESULT_NOT_FOUND"){const n=o(e.details),i=c(n.handle)??"unknown",s=c(n.sessionDir);return[`handle not found: ${i}`,...s?["",`session: ${s}`]:[],"","The artifact may have been cleared or was never saved."].join(`
19
20
  `)}if(e.code==="SESSION_WORKSPACE_NOT_INITIALIZED")return["Session workspace is not initialized.","","Create a session:","aib session init --name <name>","","Refresh session guidance:","aib help session"].join(`
20
- `);if(e.code==="AMBIGUOUS_ENTITY_SELECTOR")return g(e);if(e.code==="INVALID_PATH_ALIAS_TARGET"||e.code==="SESSION_ALIASES_SET_USAGE")return["invalid path alias","","Use:","aib session aliases set <name> <path>","","Example:","aib session aliases set svc src/services"].join(`
21
- `);if(e.code==="AIB_CONFIG_INVALID"||e.code==="INVALID_PATH_ALIASES"||e.code==="INVALID_PATH_ALIAS_NAME"||e.code==="INVALID_PATH_ALIAS_TARGET"||e.code==="RESERVED_PATH_ALIAS_NAME")return h(e);if(e.code==="UNKNOWN_SESSION_PREF"){const n=a(e.details),s=Array.isArray(n.available)?n.available.filter(i=>typeof i=="string"):[];return[e.message.toLowerCase(),...s.length>0?["","Available prefs:",...s.slice(0,12).map(i=>`- ${i}`),...s.length>12?[`+ ${s.length-12} more`]:[]]:[],"","Run:","aib session prefs get --all"].join(`
21
+ `);if(e.code==="AMBIGUOUS_ENTITY_SELECTOR")return E(e);if(e.code==="INVALID_PATH_ALIAS_TARGET"||e.code==="SESSION_ALIASES_SET_USAGE")return["invalid path alias","","Use:","aib session aliases set <name> <path>","","Example:","aib session aliases set svc src/services"].join(`
22
+ `);if(e.code==="AIB_CONFIG_INVALID"||e.code==="INVALID_PATH_ALIASES"||e.code==="INVALID_PATH_ALIAS_NAME"||e.code==="INVALID_PATH_ALIAS_TARGET"||e.code==="RESERVED_PATH_ALIAS_NAME")return y(e);if(e.code==="UNKNOWN_SESSION_PREF"){const n=o(e.details),i=Array.isArray(n.available)?n.available.filter(s=>typeof s=="string"):[];return[e.message.toLowerCase(),...i.length>0?["","Available prefs:",...i.slice(0,12).map(s=>`- ${s}`),...i.length>12?[`+ ${i.length-12} more`]:[]]:[],"","Run:","aib session prefs get --all"].join(`
22
23
  `)}if(e.code==="INVALID_SESSION_PREF_VALUE")return["invalid session preference value","",e.message,"","Run:","aib session prefs get --all"].join(`
23
24
  `);if(e.code==="UNKNOWN_SESSION_PREFS_COMMAND")return["unknown session prefs command","","Use:","aib session prefs get","aib session prefs set <key> <value>","aib session prefs clear [key]"].join(`
24
25
  `);if(e.code==="UNKNOWN_SESSION_ALIASES_COMMAND")return["unknown session aliases command","","Use:","aib session aliases get","aib session aliases set <name> <path>","aib session aliases clear [name]"].join(`
25
- `);if(e.code==="UNKNOWN_PATH_ALIAS"){const n=a(e.details),s=c(n.alias),i=Array.isArray(n.available)?n.available.filter(t=>typeof t=="string"):[];return[`unknown AIB path alias: @${s??""}`,"",i.length>0?`Available aliases: ${i.map(t=>`@${t}`).join(", ")}`:"No AIB path aliases are configured.",...i.length>0?["Run:","aib sync"]:["Check config:","aib config","or run:","aib sync"]].join(`
26
- `)}return null}function g(e){const n=a(e.details),s=Array.isArray(n.ambiguities)?n.ambiguities.filter(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)):[];if(s.length>0){const t=s.map(l=>c(l.entity)).filter(l=>l!==null),o=[t.length===1?`ambiguous entity: ${t[0]}`:`ambiguous entities: ${t.join(", ")}`,"","Use available:"];for(const l of s){const d=Array.isArray(l.suggestions)?l.suggestions.filter(u=>typeof u=="string"&&u.length>0):[];d.length>0&&o.push(`- ${d.join(", ")}`)}return o.join(`
27
- `)}const i=Array.isArray(n.suggestions)?n.suggestions.filter(t=>typeof t=="string"&&t.length>0):[];return[e.message,...i.length>0?["","Use available:",`- ${i.join(", ")}`]:[]].join(`
28
- `)}function h(e){const n=["aib config invalid","",e.message];if(e.code==="INVALID_PATH_ALIAS_NAME"&&n.push("Use alias names without @, for example:",'"pathAliases": {',' "svc": "src/services"',"}"),e.code==="RESERVED_PATH_ALIAS_NAME"){const s=a(e.details),i=Array.isArray(s.reserved)?s.reserved.filter(t=>typeof t=="string"):[];i.length>0&&n.push(`Reserved aliases: ${i.join(", ")}`)}return n.push("","Edit aib.json, then run:","aib sync"),n.join(`
29
- `)}function a(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function c(e){return typeof e=="string"&&e.length>0?e:null}
26
+ `);if(e.code==="UNKNOWN_PATH_ALIAS"){const n=o(e.details),i=c(n.alias),s=Array.isArray(n.available)?n.available.filter(t=>typeof t=="string"):[];return[`unknown AIB path alias: @${i??""}`,"",s.length>0?`Available aliases: ${s.map(t=>`@${t}`).join(", ")}`:"No AIB path aliases are configured.",...s.length>0?["Run:","aib sync"]:["Check config:","aib config","or run:","aib sync"]].join(`
27
+ `)}return null}function E(e){const n=o(e.details),i=Array.isArray(n.ambiguities)?n.ambiguities.filter(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)):[];if(i.length>0){const t=i.map(r=>c(r.entity)).filter(r=>r!==null),a=[t.length===1?`ambiguous entity: ${t[0]}`:`ambiguous entities: ${t.join(", ")}`,"","Use available:"];for(const r of i){const d=Array.isArray(r.suggestions)?r.suggestions.filter(u=>typeof u=="string"&&u.length>0):[];d.length>0&&a.push(`- ${d.join(", ")}`)}return a.join(`
28
+ `)}const s=Array.isArray(n.suggestions)?n.suggestions.filter(t=>typeof t=="string"&&t.length>0):[];return[e.message,...s.length>0?["","Use available:",`- ${s.join(", ")}`]:[]].join(`
29
+ `)}function y(e){const n=["aib config invalid","",e.message];if(e.code==="INVALID_PATH_ALIAS_NAME"&&n.push("Use alias names without @, for example:",'"pathAliases": {',' "svc": "src/services"',"}"),e.code==="RESERVED_PATH_ALIAS_NAME"){const i=o(e.details),s=Array.isArray(i.reserved)?i.reserved.filter(t=>typeof t=="string"):[];s.length>0&&n.push(`Reserved aliases: ${s.join(", ")}`)}return n.push("","Edit aib.json, then run:","aib sync"),n.join(`
30
+ `)}function o(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function c(e){return typeof e=="string"&&e.length>0?e:null}
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveStdinExampleShell=r,exports.formatStdinExamples=n;function r(){const e=process.env.AIB_HELP_SHELL?.trim().toLowerCase();return e==="bash"||e==="sh"||e==="zsh"?"bash":e==="powershell"||e==="pwsh"||e==="ps"||process.platform==="win32"?"powershell":"bash"}function n(e={}){return r()==="powershell"?t(e):s(e)}function t(e){return["PowerShell:","@'","<input>","'@ | aib <command> --stdin","","@'","tree . +onlyDirs limit=20","'@ | aib inspect --stdin",...e.includeQr===!0?["","@'","qr package.json h=20","'@ | aib qr --stdin"]:[]].join(`
2
+ `)}function s(e){return["Bash/Zsh:","aib <command> --stdin <<'EOF'","<input>","EOF","","aib inspect --stdin <<'EOF'","tree . +onlyDirs limit=20","EOF",...e.includeQr===!0?["","aib qr --stdin <<'EOF'","qr package.json h=20","EOF"]:[]].join(`
3
+ `)}
@@ -1,3 +1,5 @@
1
- "use strict";var S=exports&&exports.__createBinding||(Object.create?(function(e,r,n,c){c===void 0&&(c=n);var t=Object.getOwnPropertyDescriptor(r,n);(!t||("get"in t?!r.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return r[n]}}),Object.defineProperty(e,c,t)}):(function(e,r,n,c){c===void 0&&(c=n),e[c]=r[n]})),h=exports&&exports.__setModuleDefault||(Object.create?(function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}):function(e,r){e.default=r}),_=exports&&exports.__importStar||(function(){var e=function(r){return e=Object.getOwnPropertyNames||function(n){var c=[];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(c[c.length]=t);return c},e(r)};return function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var c=e(r),t=0;t<c.length;t++)c[t]!=="default"&&S(n,r,c[t]);return h(n,r),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.startTrace=D;const i=_(require("node:fs")),a=_(require("node:path")),w=require("node:crypto"),A=require("../observability/context"),C=require("../observability/failure-snapshot"),P=require("../observability/recent");function D(e){if(!e.traceDir||e.traceDir.trim()==="")return M();const r=x(e.cwd,e.traceDir.trim()),n=a.basename(r),c=new Date(e.startedAtMs).toISOString(),t=k(e.command,e.startedAtMs),u=a.join(r,"calls",t),m=a.join(u,"request.json"),b=(0,A.buildCorrelationContext)(e.cwd);return i.mkdirSync(u,{recursive:!0}),f(m,{callId:t,traceCallId:t,traceRunId:n,startedAt:c,cwd:a.resolve(e.cwd),...b,argv:e.argv,command:e.command,restArgs:e.restArgs,hasStdinPayload:e.stdinPayload!==void 0,stdinPayload:v(e.stdinPayload)}),{enabled:!0,traceDir:r,callId:t,callDir:u,complete(s){const g=new Date(e.startedAtMs+s.durationMs).toISOString(),I=a.join(u,"response.json"),p=a.join(u,"meta.json");f(I,s.output);const O=T(s),j=(0,C.captureFailureSnapshot)({cwd:e.cwd,command:e.command,restArgs:e.restArgs,...e.stdinPayload!==void 0?{stdinPayload:e.stdinPayload}:{},output:s.output,traceCallId:t,traceRunId:n}),d={callId:t,traceCallId:t,traceRunId:n,startedAt:c,finishedAt:g,durationMs:s.durationMs,exitCode:s.exitCode,ok:O,command:e.command,cwd:a.resolve(e.cwd),...b,selectedInstance:J(s.output),responseSummary:N(s.output),transport:s.transport??F(s.output)??null,executionId:E(s.output),...j?{failureSnapshot:j}:{},requestPath:m,responsePath:I,metaPath:p};f(p,d),$(a.join(r,"trace.jsonl"),d),(0,P.recordRecentTraceCall)(e.cwd,{traceCallId:t,traceRunId:n,traceDir:r,command:e.command,cwd:a.resolve(e.cwd),startedAt:c,finishedAt:g,ok:O,...typeof d.executionId=="string"?{executionId:d.executionId}:{}})}}}function M(){return{enabled:!1,traceDir:null,callId:null,callDir:null,complete(){}}}function x(e,r){return a.resolve(a.isAbsolute(r)?r:a.join(e,r))}function k(e,r){return`${new Date(r).toISOString().replace(/[:.]/g,"-")}-${q(e)}-${process.pid}-${(0,w.randomUUID)().slice(0,8)}`}function q(e){return e.replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"").toLowerCase()||"command"}function f(e,r){i.mkdirSync(a.dirname(e),{recursive:!0}),i.writeFileSync(e,`${JSON.stringify(r,null,2)}
2
- `)}function $(e,r){i.mkdirSync(a.dirname(e),{recursive:!0}),i.appendFileSync(e,`${JSON.stringify(r)}
3
- `)}function v(e){return e===void 0?null:y(e)}function y(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:Array.isArray(e)?e.map(r=>y(r)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,y(n)])):String(e)}function J(e){const r=e.selectedInstance;if(!r||typeof r!="object"||Array.isArray(r))return null;const n=r;return{instanceId:o(n.instanceId),reason:o(n.reason),matchedWorkspace:o(n.matchedWorkspace),port:typeof n.port=="number"?n.port:null}}function N(e){return{ok:typeof e.ok=="boolean"?e.ok:null,code:o(e.code),error:o(e.error),command:o(e.command),responseOk:V(e),responseCode:B(e),batchOk:typeof e.batchOk=="boolean"?e.batchOk:null,result:l(e.result)}}function T(e){return e.output.ok===!1?!1:e.exitCode===0}function F(e){const r=e.selectedInstance;!r||typeof r!="object"||Array.isArray(r)}function V(e){const r=l(e.response);return typeof r?.ok=="boolean"?r.ok:null}function B(e){const r=l(e.response);return r?o(r.code):null}function l(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function o(e){return typeof e=="string"?e:null}function E(e){if(typeof e.executionId=="string")return e.executionId;const r=l(e.response);return typeof r?.executionId=="string"?r.executionId:null}
1
+ "use strict";var O=exports&&exports.__createBinding||(Object.create?(function(e,t,r,a){a===void 0&&(a=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,n)}):(function(e,t,r,a){a===void 0&&(a=r),e[a]=t[r]})),_=exports&&exports.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),I=exports&&exports.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(r){var a=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(a[a.length]=n);return a},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var a=e(t),n=0;n<a.length;n++)a[n]!=="default"&&O(r,t,a[n]);return _(r,t),r}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.startTrace=J;const i=I(require("node:fs")),s=I(require("node:path")),A=require("node:crypto"),C=require("../observability/context"),x=require("../observability/failure-snapshot"),q=require("../observability/recent"),P=2;function J(e){if(!e.traceDir||e.traceDir.trim()==="")return j();let t,r,a,n,l,f,c;try{t=M(e.cwd,e.traceDir.trim()),r=$(e.startedAtMs),a=new Date(e.startedAtMs).toISOString(),n=T(e.command,e.startedAtMs),l=s.join(t,"calls",n),f=(0,C.buildCorrelationContext)(e.cwd),c=v(l),h(l),o(c.argvPath,{schemaVersion:P,callId:n,traceCallId:n,traceRunId:r,startedAt:a,cwd:s.resolve(e.cwd),...f,argv:e.argv,command:e.command,restArgs:e.restArgs,inputSource:e.stdinSource?.format??(e.stdinPayload!==void 0?"payload":"none"),hasStdinPayload:e.stdinPayload!==void 0,hasRawStdin:typeof e.stdinSource?.text=="string"}),typeof e.stdinSource?.text=="string"&&w(c.stdinPath,e.stdinSource.text),e.stdinPayload!==void 0&&o(c.inputJsonPath,g(e.stdinPayload)),o(c.legacyRequestPath,{schemaVersion:P,callId:n,traceCallId:n,traceRunId:r,startedAt:a,cwd:s.resolve(e.cwd),...f,argv:e.argv,command:e.command,restArgs:e.restArgs,inputSource:e.stdinSource??null,hasStdinPayload:e.stdinPayload!==void 0,stdinPayload:E(e.stdinPayload),files:{argvPath:c.argvPath,...typeof e.stdinSource?.text=="string"?{stdinPath:c.stdinPath}:{},...e.stdinPayload!==void 0?{inputJsonPath:c.inputJsonPath}:{}}})}catch(u){return j(U(u))}return{enabled:!0,traceDir:t,callId:n,callDir:l,complete(u){try{const S=new Date(e.startedAtMs+u.durationMs).toISOString();o(c.responseJsonPath,u.output),typeof u.stdoutText=="string"&&w(c.responseStdoutPath,u.stdoutText);const p=V(u),b=(0,x.captureFailureSnapshot)({cwd:e.cwd,command:e.command,restArgs:e.restArgs,...e.stdinPayload!==void 0?{stdinPayload:e.stdinPayload}:{},output:u.output,traceCallId:n,traceRunId:r}),y={schemaVersion:P,callId:n,traceCallId:n,traceRunId:r,startedAt:a,finishedAt:S,durationMs:u.durationMs,exitCode:u.exitCode,ok:p,command:e.command,cwd:s.resolve(e.cwd),...f,selectedInstance:N(u.output),responseSummary:R(u.output),transport:u.transport??F(u.output)??null,executionId:L(u.output),...b?{failureSnapshot:b}:{},requestPath:c.legacyRequestPath,requestArgvPath:c.argvPath,...typeof e.stdinSource?.text=="string"?{requestStdinPath:c.stdinPath}:{},...e.stdinPayload!==void 0?{requestInputJsonPath:c.inputJsonPath}:{},responsePath:c.responseJsonPath,responseJsonPath:c.responseJsonPath,...typeof u.stdoutText=="string"?{responseStdoutPath:c.responseStdoutPath}:{},metaPath:c.metaPath};o(c.metaPath,y),k(s.join(t,"trace.jsonl"),y),(0,q.recordRecentTraceCall)(e.cwd,{traceCallId:n,traceRunId:r,traceDir:t,command:e.command,cwd:s.resolve(e.cwd),startedAt:a,finishedAt:S,ok:p,...typeof y.executionId=="string"?{executionId:y.executionId}:{}})}catch{}}}}function v(e){return{argvPath:s.join(e,"request.argv.json"),stdinPath:s.join(e,"request.stdin.txt"),inputJsonPath:s.join(e,"request.input.json"),legacyRequestPath:s.join(e,"request.json"),responseStdoutPath:s.join(e,"response.stdout.txt"),responseJsonPath:s.join(e,"response.json"),metaPath:s.join(e,"meta.json")}}function j(e){return{enabled:!1,traceDir:null,callId:null,callDir:null,...e?{disabledReason:e}:{},complete(){}}}function M(e,t){return s.resolve(s.isAbsolute(t)?t:s.join(e,t))}function T(e,t){return`${new Date(t).toISOString().replace(/[:.]/g,"-")}-${D(e)}-${process.pid}-${(0,A.randomUUID)().slice(0,8)}`}function $(e){return`run_${new Date(e).toISOString().replace(/[:.]/g,"-")}_${process.pid}`}function D(e){return e.replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"").toLowerCase()||"command"}function o(e,t){h(s.dirname(e)),i.writeFileSync(e,`${JSON.stringify(t,null,2)}
2
+ `)}function w(e,t){h(s.dirname(e)),i.writeFileSync(e,t.endsWith(`
3
+ `)?t:`${t}
4
+ `,"utf8")}function k(e,t){h(s.dirname(e)),i.appendFileSync(e,`${JSON.stringify(t)}
5
+ `)}function h(e){try{i.mkdirSync(e,{recursive:!0});return}catch(t){if((typeof t=="object"&&t!==null&&"code"in t?String(t.code):"")!=="ENOENT")throw t}i.mkdirSync(s.dirname(e),{recursive:!0}),i.mkdirSync(e,{recursive:!0})}function E(e){return e===void 0?null:g(e)}function g(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:Array.isArray(e)?e.map(t=>g(t)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,r])=>[t,g(r)])):String(e)}function N(e){const t=e.selectedInstance;if(!t||typeof t!="object"||Array.isArray(t))return null;const r=t;return{instanceId:d(r.instanceId),reason:d(r.reason),matchedWorkspace:d(r.matchedWorkspace),port:typeof r.port=="number"?r.port:null}}function R(e){return{ok:typeof e.ok=="boolean"?e.ok:null,code:d(e.code),error:d(e.error),command:d(e.command),responseOk:W(e),responseCode:B(e),batchOk:typeof e.batchOk=="boolean"?e.batchOk:null,result:m(e.result)}}function V(e){return e.output.ok===!1?!1:e.exitCode===0}function F(e){const t=e.selectedInstance;!t||typeof t!="object"||Array.isArray(t)}function W(e){const t=m(e.response);return typeof t?.ok=="boolean"?t.ok:null}function B(e){const t=m(e.response);return t?d(t.code):null}function m(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function d(e){return typeof e=="string"?e:null}function L(e){if(typeof e.executionId=="string")return e.executionId;const t=m(e.response);return typeof t?.executionId=="string"?t.executionId:null}function U(e){return e instanceof Error?e.message:String(e)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automaton-labs/aib",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "CLI for discovering and calling the local aib IDE extension runtime.",
5
5
  "publishConfig": {
6
6
  "access": "public"
Binary file
Binary file
@@ -223,7 +223,31 @@ function defaultManifestUrl() {
223
223
  function runtimeComplete() {
224
224
  return fs.existsSync(path.join(runtimesDir, "code-server", "node_modules", "code-server", "out", "node", "entry.js"))
225
225
  && Boolean(findPackagedBrowserRuntime())
226
- && Boolean(findPackagedNodeRuntime());
226
+ && Boolean(findPackagedNodeRuntime())
227
+ && runtimePlatformStatus().ok;
228
+ }
229
+
230
+ function runtimePlatformStatus() {
231
+ const markerPath = path.join(runtimesDir, ".aib-runtime-platform.json");
232
+ if (!fs.existsSync(markerPath)) {
233
+ return { ok: true, reason: "missing", expectedPlatformKey: platformKey, actualPlatformKey: null };
234
+ }
235
+ try {
236
+ const marker = JSON.parse(fs.readFileSync(markerPath, "utf8"));
237
+ const actualPlatformKey = typeof marker.platformKey === "string"
238
+ ? marker.platformKey
239
+ : typeof marker.platform === "string" && typeof marker.arch === "string"
240
+ ? `${marker.platform}-${marker.arch}`
241
+ : null;
242
+ return {
243
+ ok: actualPlatformKey === platformKey,
244
+ reason: actualPlatformKey === platformKey ? "ok" : "mismatch",
245
+ expectedPlatformKey: platformKey,
246
+ actualPlatformKey
247
+ };
248
+ } catch {
249
+ return { ok: false, reason: "invalid", expectedPlatformKey: platformKey, actualPlatformKey: null };
250
+ }
227
251
  }
228
252
 
229
253
  function findPackagedNodeRuntime() {