@zortexhq/indra-v2.5 0.2.3 → 0.2.4

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 (33) hide show
  1. package/dist/measurement-context.js +1 -1
  2. package/dist/product-feedback.js +2 -2
  3. package/dist/profile.js +1 -1
  4. package/node_modules/@zortexhq/plugin-galaxy-ui/dist/galaxy-text.js +1 -1
  5. package/node_modules/@zortexhq/plugin-galaxy-ui/dist/localizer.js +1 -1
  6. package/node_modules/@zortexhq/plugin-galaxy-ui/dist/routes.js +1 -1
  7. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/account.js +1 -1
  8. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-i18n-twin.js +1 -0
  9. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-i18n.js +1 -1
  10. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-model.js +1 -1
  11. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-text.js +1 -1
  12. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app.html +92 -36
  13. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/connection-panel.js +1 -0
  14. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/galaxy-renderer.js +13 -0
  15. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/galaxy.html +141 -0
  16. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/live-model.js +1 -1
  17. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/live-state.js +1 -1
  18. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/panels-live.js +3 -3
  19. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/product.js +1 -1
  20. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/shell.css +16 -46
  21. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/shell.js +1 -1
  22. package/node_modules/@zortexhq/plugin-posthog/dist/activity.js +1 -0
  23. package/node_modules/@zortexhq/plugin-posthog/dist/northstar.js +1 -1
  24. package/node_modules/@zortexhq/plugin-telemetry/dist/api/measurement.js +1 -1
  25. package/node_modules/@zortexhq/plugin-telemetry/dist/api/telemetry.js +1 -1
  26. package/node_modules/@zortexhq/plugin-telemetry/dist/device-identity.js +1 -0
  27. package/node_modules/@zortexhq/plugin-telemetry/dist/index.js +1 -1
  28. package/package.json +6 -6
  29. package/profiles/core.yml +1 -0
  30. package/release-provenance.json +13 -13
  31. package/update-manifest.json +91 -67
  32. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-catalog.js +0 -1
  33. package/node_modules/@zortexhq/plugin-galaxy-ui/src/integration/demo.js +0 -1
@@ -1 +1 @@
1
- import{DatabaseSync}from"node:sqlite";import{mkdir,lstat,realpath}from"node:fs/promises";import{isAbsolute,join,resolve}from"node:path";import{createHash,createHmac,randomUUID}from"node:crypto";import{businessError,canonicalJson,ok}from"@zortexhq/plugin-connector-framework/api";import{currentOperationalExecution}from"./api/operational.js";import{isUsageEvent,isUsageContext,isUsageFeedbackInput,isFlowId,snapshotUsageRecord,currentFeedbackFlow,currentTelemetryContext,currentUsageInvocation,isUsageObservation,snapshotUsageObservation,OBSERVATION_SNAPSHOT_INTERVAL_MS,OBSERVATION_SNAPSHOT_DAILY_LIMIT,feedbackEligible,FEEDBACK_CHANNELS}from"./api/index.js";export{aggregateUsage}from"./aggregate.js";export const name="zortex-telemetry";export const TELEMETRY_RETENTION_DAYS=30,TELEMETRY_MAX_EVENTS=5e4,TELEMETRY_MAX_RECORD_BYTES=2048;const DAY=864e5,FEEDBACK_DAYS=7;export async function createTelemetry({root,enabled=true,startup=false,newInstallation=false,context=currentTelemetryContext()},runtime={}){if(typeof newInstallation!=="boolean")throw Error("newInstallation must be boolean.");if(!isAbsolute(root)||typeof enabled!=="boolean"||typeof startup!=="boolean")throw Error("Telemetry root must be absolute; enabled must be boolean.");const capturedContext=context?Object.freeze({...context}):void 0;if(context!==void 0&&!isUsageContext(capturedContext))throw Error("Invalid telemetry runtime context.");await mkdir(root,{recursive:true,mode:448});if((await lstat(root)).isSymbolicLink())throw Error("Telemetry root cannot be a link.");const file=join(await realpath(root),"telemetry.sqlite");if((await lstat(file).catch(()=>null))?.isSymbolicLink())throw Error("Telemetry database cannot be a link.");const db=new DatabaseSync(file),now=runtime.now??Date.now;let created=false,userId="",actionSalt="",closed=false,initializing=false,nextAgeSweep=0;try{db.exec("PRAGMA busy_timeout=3000;PRAGMA journal_mode=WAL;BEGIN IMMEDIATE");initializing=true;db.exec("CREATE TABLE IF NOT EXISTS identity(id INTEGER PRIMARY KEY CHECK(id=1),user TEXT NOT NULL);CREATE TABLE IF NOT EXISTS usage(id TEXT PRIMARY KEY,at TEXT NOT NULL,operation TEXT NOT NULL,outcome TEXT NOT NULL,duration REAL NOT NULL,source TEXT,code TEXT,internal INTEGER NOT NULL DEFAULT 0);");const columns=new Set(db.prepare("PRAGMA table_info(usage)").all().map(column=>String(column.name)));for(const[column,type]of[["internal","INTEGER NOT NULL DEFAULT 0"],["trace","TEXT"],["metadata","TEXT"],["feedback_target","TEXT"],["feedback_channel","TEXT"],["observation_key","TEXT"],["observation_fingerprint","TEXT"],["observation_scope","TEXT"],["observation_recorded_at","INTEGER"]])if(!columns.has(column))db.exec(`ALTER TABLE usage ADD COLUMN ${column} ${type}`);created=Number(db.prepare("INSERT OR IGNORE INTO identity(id,user) VALUES(1,?)").run(randomUUID()).changes)===1;userId=String(db.prepare("SELECT user FROM identity").get().user);if(!db.prepare("PRAGMA table_info(identity)").all().some(column=>column.name==="action_salt"))db.exec("ALTER TABLE identity ADD COLUMN action_salt TEXT");if(enabled){db.prepare("UPDATE identity SET action_salt=? WHERE id=1 AND action_salt IS NULL").run(randomUUID());actionSalt=String(db.prepare("SELECT action_salt FROM identity WHERE id=1").get().action_salt)}db.exec("CREATE TABLE IF NOT EXISTS usage_export_seq(seq INTEGER PRIMARY KEY AUTOINCREMENT,event_id TEXT UNIQUE NOT NULL);CREATE TABLE IF NOT EXISTS collection_state(id INTEGER PRIMARY KEY CHECK(id=1),retained_events INTEGER NOT NULL,pruned_events INTEGER NOT NULL DEFAULT 0,retention_floor INTEGER NOT NULL DEFAULT 0,sequence_backfilled INTEGER NOT NULL DEFAULT 0);");if(!db.prepare("SELECT id FROM collection_state WHERE id=1").get())db.exec("INSERT INTO collection_state(id,retained_events) SELECT 1,COUNT(*) FROM usage;");if(!db.prepare("SELECT sequence_backfilled FROM collection_state WHERE id=1").get().sequence_backfilled){db.exec("INSERT OR IGNORE INTO usage_export_seq(event_id) SELECT id FROM usage ORDER BY at,id;UPDATE collection_state SET sequence_backfilled=1 WHERE id=1;")}db.exec("CREATE INDEX IF NOT EXISTS usage_at ON usage(at,id);CREATE UNIQUE INDEX IF NOT EXISTS usage_feedback_once ON usage(feedback_target,feedback_channel) WHERE feedback_target IS NOT NULL;CREATE UNIQUE INDEX IF NOT EXISTS usage_observation_once ON usage(observation_key) WHERE observation_key IS NOT NULL;CREATE INDEX IF NOT EXISTS usage_observation_scope ON usage(observation_scope,observation_recorded_at) WHERE observation_scope IS NOT NULL;CREATE INDEX IF NOT EXISTS usage_observation_budget ON usage(observation_recorded_at) WHERE observation_scope IS NOT NULL;CREATE TABLE IF NOT EXISTS observation_counters(id INTEGER PRIMARY KEY CHECK(id=1),rate_limited INTEGER NOT NULL DEFAULT 0,budget_limited INTEGER NOT NULL DEFAULT 0,unchanged INTEGER NOT NULL DEFAULT 0,duplicates INTEGER NOT NULL DEFAULT 0,last_suppressed_at TEXT);INSERT OR IGNORE INTO observation_counters(id) VALUES(1);CREATE TRIGGER IF NOT EXISTS usage_count_insert AFTER INSERT ON usage BEGIN UPDATE collection_state SET retained_events=retained_events+1 WHERE id=1;END;CREATE TRIGGER IF NOT EXISTS usage_count_delete AFTER DELETE ON usage BEGIN UPDATE collection_state SET retained_events=retained_events-1 WHERE id=1;END;COMMIT;PRAGMA busy_timeout=20;");initializing=false}catch(error){if(initializing){try{db.exec("ROLLBACK")}catch{}}db.close();throw error}const state=db.prepare("SELECT retained_events,pruned_events,retention_floor FROM collection_state WHERE id=1");const add=db.prepare("INSERT OR IGNORE INTO usage(id,at,operation,outcome,duration,source,code,internal,trace,metadata,feedback_target,feedback_channel) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)");const addSequence=db.prepare("INSERT INTO usage_export_seq(event_id) VALUES(?)");const byId=db.prepare("SELECT * FROM usage WHERE id=?");const byFeedback=db.prepare("SELECT * FROM usage WHERE feedback_target=? AND feedback_channel=?");const pageQuery=db.prepare("SELECT s.seq,u.* FROM usage_export_seq s JOIN usage u ON u.id=s.event_id WHERE s.seq>? ORDER BY s.seq LIMIT ?");const pruneFacts=db.prepare("SELECT COUNT(*) AS n,COALESCE(MAX(s.seq),0) AS last_seq FROM usage_export_seq s JOIN usage u ON u.id=s.event_id WHERE u.id IN (SELECT id FROM usage WHERE id<>? AND at<? ORDER BY at,id LIMIT ?)");const pruneSequences=db.prepare("DELETE FROM usage_export_seq WHERE event_id IN (SELECT id FROM usage WHERE id<>? AND at<? ORDER BY at,id LIMIT ?)");const pruneRows=db.prepare("DELETE FROM usage WHERE id IN (SELECT id FROM usage WHERE id<>? AND at<? ORDER BY at,id LIMIT ?)");const rememberPruning=db.prepare("UPDATE collection_state SET pruned_events=pruned_events+?,retention_floor=MAX(retention_floor,?) WHERE id=1");const oldest=db.prepare("SELECT MIN(at) AS at FROM usage WHERE id<>?");const observationByKey=db.prepare("SELECT id,observation_fingerprint FROM usage WHERE observation_key=?");const lastSnapshot=db.prepare("SELECT observation_fingerprint,observation_recorded_at FROM usage WHERE observation_scope=? ORDER BY observation_recorded_at DESC,id DESC LIMIT 1");const snapshotBudget=db.prepare("SELECT COUNT(*) AS n FROM usage WHERE observation_scope IS NOT NULL AND observation_recorded_at>=? AND observation_recorded_at<?");const observationMetadata=db.prepare("UPDATE usage SET observation_key=?,observation_fingerprint=?,observation_scope=?,observation_recorded_at=? WHERE id=?");const observationCounters=db.prepare("SELECT * FROM observation_counters WHERE id=1");const perform=async fn=>{if(closed)return businessError("unavailable","Telemetry is inactive.","storage");try{return fn()}catch(error){return businessError(error.errcode===5?"unavailable":"data_loss","Telemetry operation failed.","storage")}};const captureIdentity=enabled?{producerRef:randomUUID(),since:new Date(now()).toISOString()}:void 0;const captureCounts={attempted:0,accepted:0,suppressed:0,rejected:0,failed:0};const capture=async fn=>{if(!enabled||closed)return perform(fn);captureCounts.attempted++;const result=await perform(fn);if("ok"in result)captureCounts[result.ok.recorded?"accepted":"suppressed"]++;else if("err"in result&&["invalid_argument","already_exists"].includes(result.err.code))captureCounts.rejected++;else captureCounts.failed++;return result};function collection(after=0){const row=state.get(),stats=observationCounters.get();return{retainedEvents:Number(row.retained_events),prunedEvents:Number(row.pruned_events),retentionFloor:Number(row.retention_floor),limited:after<Number(row.retention_floor),retentionDays:TELEMETRY_RETENTION_DAYS,maxEvents:TELEMETRY_MAX_EVENTS,oldestAvailableAt:oldest.get(userId).at,observations:{snapshotRateLimited:Number(stats.rate_limited),snapshotBudgetLimited:Number(stats.budget_limited),snapshotUnchanged:Number(stats.unchanged),duplicates:Number(stats.duplicates),lastSuppressedAt:stats.last_suppressed_at}}}function decode(row){const metadata=row.metadata?JSON.parse(String(row.metadata)):{};return{id:String(row.id),at:String(row.at),operation:String(row.operation),outcome:String(row.outcome),durationMs:Number(row.duration),...row.source?{source:String(row.source)}:{},...row.code?{code:String(row.code)}:{},...row.internal?{internal:true}:{},...row.trace?{trace:JSON.parse(String(row.trace))}:{},...metadata}}function prune(cutoff,limit){const facts=pruneFacts.get(userId,cutoff,limit);if(!Number(facts.n))return;pruneSequences.run(userId,cutoff,limit);pruneRows.run(userId,cutoff,limit);rememberPruning.run(Number(facts.n),Number(facts.last_seq))}function maintain(){const now2=Date.now();if(now2>=nextAgeSweep){prune(new Date(now2-TELEMETRY_RETENTION_DAYS*DAY).toISOString(),2147483647);nextAgeSweep=now2+6e4}const excess=Number(state.get().retained_events)-TELEMETRY_MAX_EVENTS;if(excess>0)prune("9999-12-31T23:59:59.999Z",excess+Math.min(255,TELEMETRY_MAX_EVENTS-1))}function insert(event,id=randomUUID(),transaction=true,at=new Date().toISOString()){const execution=["product.resources","product.collection"].includes(event.operation)?void 0:currentOperationalExecution();const record={...event,id,at,...capturedContext?{context:capturedContext}:{},...execution?{execution}:{}};if(Buffer.byteLength(JSON.stringify(record))>TELEMETRY_MAX_RECORD_BYTES)throw Error("Telemetry record exceeds its closed metadata budget.");const metadata={...record.context?{context:record.context}:{},...record.execution?{execution:record.execution}:{},...event.operational?{operational:event.operational}:{},...event.resource?{resource:event.resource}:{},...event.collectionStatus?{collectionStatus:event.collectionStatus}:{},...event.result?{result:event.result}:{},...event.correlation?{correlation:event.correlation}:{},...event.errorCategory?{errorCategory:event.errorCategory}:{},...event.feedback?{feedback:event.feedback}:{},...event.observation?{observation:event.observation}:{},...event.invocation?{invocation:event.invocation}:{}};if(transaction)db.exec("BEGIN IMMEDIATE");try{const inserted=add.run(id,at,event.operation,event.outcome,event.durationMs,event.source??null,event.code??null,Number(event.internal??false),event.trace?JSON.stringify(event.trace):null,Object.keys(metadata).length?JSON.stringify(metadata):null,event.feedback?.targetReceiptId??null,event.feedback?.submissionChannel??null);if(Number(inserted.changes))addSequence.run(id);maintain();if(transaction)db.exec("COMMIT");return id}catch(error){if(transaction)db.exec("ROLLBACK");throw error}}if(enabled){try{db.exec("BEGIN IMMEDIATE");maintain();db.exec("COMMIT")}catch(error){try{db.exec("ROLLBACK")}catch{}db.close();throw error}}if(startup&&enabled){insert({operation:"product.first_start",outcome:"ok",durationMs:0,internal:true,code:created&&newInstallation?"new_install":"first_observed"},userId);insert({operation:"product.started",outcome:"ok",durationMs:0,internal:true})}const service={isEnabled:()=>enabled&&!closed,collectionStats:()=>!enabled||closed||!captureIdentity?void 0:{...captureIdentity,scope:"record_and_observe_api_calls",...captureCounts,pending:captureCounts.attempted-captureCounts.accepted-captureCounts.suppressed-captureCounts.rejected-captureCounts.failed},sourceReference(source){if(!enabled||closed||!actionSalt||typeof source!=="string"||!/^[a-z][a-z0-9-]{0,63}$/.test(source))return;const hash=createHmac("sha256",actionSalt).update(JSON.stringify(["zortex-source-v1",source])).digest("hex");return hash.slice(0,8)+"-"+hash.slice(8,12)+"-8"+hash.slice(13,16)+"-a"+hash.slice(17,20)+"-"+hash.slice(20,32)},actionReference(source,method){if(!enabled||closed||!actionSalt||typeof source!=="string"||!/^[a-z][a-z0-9-]{0,63}$/.test(source)||typeof method!=="string"||!method.length||Buffer.byteLength(method)>512)return;const hash=createHmac("sha256",actionSalt).update(JSON.stringify(["zortex-action-v2",source,method])).digest("hex");return hash.slice(0,8)+"-"+hash.slice(8,12)+"-8"+hash.slice(13,16)+"-a"+hash.slice(17,20)+"-"+hash.slice(20,32)},observe:input=>capture(()=>{if(!enabled)return ok({recorded:false,reason:"disabled"});const snapshot=snapshotUsageObservation(input);if(!isUsageObservation(snapshot))return businessError("invalid_argument","Observation accepts only fixed, content-free metadata and known counts.","storage");const{key,source,at,...rawFacts}=snapshot;const facts=Object.fromEntries(Object.entries(rawFacts).filter(([,value])=>value!==void 0));if(facts.kind==="connection")facts.capabilities=[...facts.capabilities].sort();const hash=value=>createHash("sha256").update(canonicalJson(value)).digest("hex");const observationKey=hash(["zortex-observation-v1",userId,snapshot.kind,source,key]);const fingerprint=hash({source,facts});const receiptId=observationKey.slice(0,8)+"-"+observationKey.slice(8,12)+"-5"+observationKey.slice(13,16)+"-a"+observationKey.slice(17,20)+"-"+observationKey.slice(20,32);const recordedAt=now(),observedAt=at??new Date(recordedAt).toISOString();const scope=facts.kind==="sync"?null:hash([facts.kind,source,facts.connectionRef??null,...facts.kind==="inventory"?[facts.population,facts.attribution]:[]]);db.exec("BEGIN IMMEDIATE");try{const prior=observationByKey.get(observationKey);if(prior){if(prior.observation_fingerprint!==fingerprint){db.exec("COMMIT");return businessError("already_exists","This observation key already has different metadata.","storage")}db.exec("UPDATE observation_counters SET duplicates=duplicates+1 WHERE id=1");db.exec("COMMIT");return ok({recorded:false,reason:"duplicate",receiptId:String(prior.id)})}if(scope){const previous=lastSnapshot.get(scope),elapsed=recordedAt-Number(previous?.observation_recorded_at??0);const unchanged=previous&&previous.observation_fingerprint===fingerprint&&elapsed<DAY;const limited=previous&&elapsed<OBSERVATION_SNAPSHOT_INTERVAL_MS;const dayStart=Math.floor(recordedAt/DAY)*DAY;const budget=Number(snapshotBudget.get(dayStart,dayStart+DAY).n)>=OBSERVATION_SNAPSHOT_DAILY_LIMIT;if(unchanged||limited||budget){const field=unchanged?"unchanged":limited?"rate_limited":"budget_limited";db.prepare(`UPDATE observation_counters SET ${field}=${field}+1,last_suppressed_at=? WHERE id=1`).run(new Date(recordedAt).toISOString());db.exec("COMMIT");return ok({recorded:false,reason:unchanged?"unchanged":"rate_limited"})}}const outcome=facts.kind!=="sync"?"ok":facts.status==="completed"?"ok":facts.status==="cancelled"?"cancelled":facts.status==="failed"||facts.status==="cleanup_blocked"?"fault":"unknown";insert({operation:"connector."+facts.kind,outcome,durationMs:facts.kind==="sync"?facts.durationMs:0,source,internal:true,observation:facts},receiptId,false,observedAt);observationMetadata.run(observationKey,fingerprint,scope,recordedAt,receiptId);db.exec("COMMIT");return ok({recorded:true,reason:"recorded",receiptId})}catch(error){db.exec("ROLLBACK");throw error}}),record:input=>capture(()=>{if(!enabled)return ok({recorded:false});const snapshot=snapshotUsageRecord(input);if(!isUsageEvent(snapshot)||snapshot.operation==="product.feedback"||snapshot.operation==="product.first_start")return businessError("invalid_argument","Usage accepts only content-free fields; startup and feedback anchors are provider-owned.","storage");const event=snapshot,flow=currentFeedbackFlow();if(!["product.resources","product.collection"].includes(event.operation)&&!event.correlation&&flow&&(!event.source||event.source===flow.source)&&isFlowId(flow.flowId))event.correlation={flowId:flow.flowId,...isFlowId(flow.connectionFlowId)?{connectionFlowId:flow.connectionFlowId}:{}};const invocation=["product.resources","product.collection"].includes(event.operation)?void 0:currentUsageInvocation();const measuredAt=event.resource?.asOf??event.collectionStatus?.asOf;return ok({recorded:true,receiptId:insert({...event,...invocation?{invocation:{...invocation}}:{}},void 0,true,measuredAt)})}),readBatch:({after=0,limit=500})=>perform(()=>{if(!Number.isSafeInteger(after)||after<0||!Number.isInteger(limit)||limit<1||limit>1e3)return businessError("invalid_argument","Usage paging needs an ordered cursor and 1\u20131000 events.","storage");const found=pageQuery.all(after,limit+1),selected=found.slice(0,limit);return ok({format:"zortex-usage/v1",userId,enabled,cursor:selected.length?Number(selected.at(-1).seq):after,more:found.length>limit,eventCursors:selected.map(row=>Number(row.seq)),events:selected.map(decode),collection:collection(after)})}),export:()=>perform(()=>{const events=db.prepare("SELECT * FROM usage ORDER BY at,id LIMIT 100001").all().map(decode);if(events.length>1e5)return businessError("resource_exhausted","Usage export exceeds its batch limit.","storage");return ok({format:"zortex-usage/v1",userId,enabled,events,collection:collection()})}),recent:({limit=5}={})=>perform(()=>{if(!Number.isInteger(limit)||limit<1||limit>20)return businessError("invalid_argument","Recent feedback needs a limit from 1 to 20.","storage");if(!enabled)return ok({enabled,events:[]});const rows=db.prepare("SELECT * FROM usage WHERE at>=? AND at<=? AND (operation IN ('search','context','sql','connector.read','connector.invoke') OR operation='action' AND code='effective_invoke') AND (internal=0 OR operation IN ('connector.read','connector.invoke')) ORDER BY at DESC,id DESC LIMIT ?").all(new Date(Date.now()-FEEDBACK_DAYS*DAY).toISOString(),new Date().toISOString(),limit);return ok({enabled,events:rows.map(row=>{const event=decode(row);return{receiptId:event.id,at:event.at,operation:event.operation,outcome:event.outcome,durationMs:event.durationMs,...event.source?{source:event.source}:{},...event.context?{context:event.context}:{},...event.result?{result:event.result}:{}}})})}),recordFeedback:(input,channel)=>perform(()=>{input={...input};channel={...channel};if(!isUsageFeedbackInput(input)||!channel||Object.keys(channel).some(key=>key!=="submissionChannel")||!FEEDBACK_CHANNELS.includes(channel.submissionChannel))return businessError("invalid_argument","Feedback needs one recent receipt, a fixed rating and an optional fixed reason.","storage");if(!enabled)return ok({recorded:false,delivery:"disabled"});db.exec("BEGIN IMMEDIATE");try{const prior=byFeedback.get(input.receiptId,channel.submissionChannel);if(prior){const feedback2=decode(prior).feedback;db.exec("COMMIT");return feedback2.rating===input.rating&&feedback2.reason===input.reason?ok({recorded:false,delivery:"queued",receiptId:String(prior.id)}):businessError("already_exists","This operation already has a different report through this channel.","storage")}const row=byId.get(input.receiptId);if(!row){db.exec("COMMIT");return businessError("not_found","The operation receipt is not available on this installation.","storage")}const target=decode(row),age=Date.now()-Date.parse(target.at);if(!feedbackEligible(target)||age<0||age>FEEDBACK_DAYS*DAY){db.exec("COMMIT");return businessError("failed_precondition","Feedback requires an eligible operation from the last seven days.","storage")}const feedback={targetReceiptId:target.id,rating:input.rating,...input.reason?{reason:input.reason}:{},submissionChannel:channel.submissionChannel,target:{operation:target.operation,outcome:target.outcome,at:target.at,...target.source?{source:target.source}:{},...target.context?{context:target.context}:{},...target.result?{result:target.result}:{}}};const receiptId=insert({operation:"product.feedback",outcome:"ok",durationMs:0,internal:true,feedback},randomUUID(),false);db.exec("COMMIT");return ok({recorded:true,delivery:"queued",receiptId})}catch(error){db.exec("ROLLBACK");throw error}}),report:()=>perform(()=>{const total=db.prepare("SELECT COUNT(*) AS calls,COALESCE(SUM(duration),0) AS duration FROM usage WHERE internal=0 AND operation NOT IN ('flywheel.start','flywheel.run','product.feedback')").get();const flywheel=db.prepare("SELECT COUNT(*) FILTER(WHERE operation='flywheel.start') AS started,COUNT(*) FILTER(WHERE operation='flywheel.run' AND outcome IN ('ok','empty')) AS completed,COUNT(*) FILTER(WHERE operation='flywheel.run' AND outcome='fault') AS failed FROM usage").get();const rows=db.prepare("SELECT source,COUNT(*) FILTER(WHERE outcome IN ('ok','empty','fault')) AS attempted,COUNT(*) FILTER(WHERE outcome='fault') AS faults,COUNT(*) FILTER(WHERE outcome='auth-blocked') AS authBlocked,COUNT(*) FILTER(WHERE outcome='cancelled') AS cancelled,COUNT(*) FILTER(WHERE outcome='invalid') AS invalid FROM usage WHERE operation IN ('connector.read','connector.invoke') AND source IS NOT NULL GROUP BY source ORDER BY source").all();const fabrication=db.prepare("SELECT source,COUNT(*) FILTER(WHERE outcome='ok') AS completed,COUNT(*) FILTER(WHERE outcome='fault') AS failed,COALESCE(SUM(duration),0) AS duration FROM usage WHERE operation='connector.fabricate' AND source IS NOT NULL GROUP BY source ORDER BY source").all();const usable=db.prepare("SELECT COUNT(*) AS n FROM usage_export_seq s JOIN usage u ON u.id=s.event_id WHERE u.operation='connector.usable' AND u.source IS NOT NULL AND u.outcome='ok' AND s.seq=(SELECT MAX(s2.seq) FROM usage_export_seq s2 JOIN usage u2 ON u2.id=s2.event_id WHERE u2.operation='connector.usable' AND u2.source=u.source)").get();return ok({enabled,userId,calls:Number(total.calls),durationMs:Number(total.duration),flywheel:{started:Number(flywheel.started),completed:Number(flywheel.completed),failed:Number(flywheel.failed)},connectors:rows.map(row=>({source:String(row.source),attempted:Number(row.attempted),faults:Number(row.faults),faultRate:Number(row.attempted)?Number(row.faults)/Number(row.attempted):null,authBlocked:Number(row.authBlocked),cancelled:Number(row.cancelled),invalid:Number(row.invalid)})),fabrication:fabrication.map(row=>({source:String(row.source),completed:Number(row.completed),failed:Number(row.failed),durationMs:Number(row.duration)})),usableConnectors:Number(usable.n),collection:collection()})}),async close(){if(!closed){closed=true;db.close()}}};return service}export async function apply(ctx,config){const freshRoot=process.env.ZORTEX_TELEMETRY_NEW_INSTALL_ROOT;const newInstallation=config.newInstallation??!!(freshRoot&&isAbsolute(freshRoot)&&typeof config.root==="string"&&resolve(freshRoot)===resolve(config.root));const service=await createTelemetry({...config,newInstallation,startup:config.startup??true});ctx.provide("zortexTelemetry",service);ctx.effect(()=>()=>service.close())}
1
+ import{DatabaseSync}from"node:sqlite";import{mkdir,lstat,realpath}from"node:fs/promises";import{isAbsolute,join,resolve}from"node:path";import{createHash,createHmac,randomUUID}from"node:crypto";import{localDeviceIdentity}from"./device-identity.js";import{businessError,canonicalJson,ok}from"@zortexhq/plugin-connector-framework/api";import{currentOperationalExecution}from"./api/operational.js";import{isUsageEvent,isUsageContext,isUsageFeedbackInput,isFlowId,snapshotUsageRecord,currentFeedbackFlow,currentTelemetryContext,currentUsageInvocation,isUsageObservation,snapshotUsageObservation,OBSERVATION_SNAPSHOT_INTERVAL_MS,OBSERVATION_SNAPSHOT_DAILY_LIMIT,feedbackEligible,FEEDBACK_CHANNELS}from"./api/index.js";export{aggregateUsage}from"./aggregate.js";export const name="zortex-telemetry";export const TELEMETRY_RETENTION_DAYS=30,TELEMETRY_MAX_EVENTS=5e4,TELEMETRY_MAX_RECORD_BYTES=2048;const DAY=864e5,FEEDBACK_DAYS=7;export async function createTelemetry({root,enabled=true,startup=false,newInstallation=false,context=currentTelemetryContext(),deviceIdentityFile},runtime={}){if(typeof newInstallation!=="boolean")throw Error("newInstallation must be boolean.");if(!isAbsolute(root)||typeof enabled!=="boolean"||typeof startup!=="boolean")throw Error("Telemetry root must be absolute; enabled must be boolean.");const deviceId=enabled&&context?.trafficClass!=="internal_test"&&context?.trafficClass!=="simulation"&&deviceIdentityFile?await localDeviceIdentity(deviceIdentityFile).catch(()=>void 0):void 0;const capturedContext=context||deviceId?Object.freeze({...context,...deviceId?{deviceId}:{}}):void 0;if(context!==void 0&&!isUsageContext(capturedContext))throw Error("Invalid telemetry runtime context.");await mkdir(root,{recursive:true,mode:448});if((await lstat(root)).isSymbolicLink())throw Error("Telemetry root cannot be a link.");const file=join(await realpath(root),"telemetry.sqlite");if((await lstat(file).catch(()=>null))?.isSymbolicLink())throw Error("Telemetry database cannot be a link.");const db=new DatabaseSync(file),now=runtime.now??Date.now;let created=false,userId="",actionSalt="",closed=false,initializing=false,nextAgeSweep=0;try{db.exec("PRAGMA busy_timeout=3000;PRAGMA journal_mode=WAL;BEGIN IMMEDIATE");initializing=true;db.exec("CREATE TABLE IF NOT EXISTS identity(id INTEGER PRIMARY KEY CHECK(id=1),user TEXT NOT NULL);CREATE TABLE IF NOT EXISTS usage(id TEXT PRIMARY KEY,at TEXT NOT NULL,operation TEXT NOT NULL,outcome TEXT NOT NULL,duration REAL NOT NULL,source TEXT,code TEXT,internal INTEGER NOT NULL DEFAULT 0);");const columns=new Set(db.prepare("PRAGMA table_info(usage)").all().map(column=>String(column.name)));for(const[column,type]of[["internal","INTEGER NOT NULL DEFAULT 0"],["trace","TEXT"],["metadata","TEXT"],["feedback_target","TEXT"],["feedback_channel","TEXT"],["observation_key","TEXT"],["observation_fingerprint","TEXT"],["observation_scope","TEXT"],["observation_recorded_at","INTEGER"]])if(!columns.has(column))db.exec(`ALTER TABLE usage ADD COLUMN ${column} ${type}`);created=Number(db.prepare("INSERT OR IGNORE INTO identity(id,user) VALUES(1,?)").run(randomUUID()).changes)===1;userId=String(db.prepare("SELECT user FROM identity").get().user);if(!db.prepare("PRAGMA table_info(identity)").all().some(column=>column.name==="action_salt"))db.exec("ALTER TABLE identity ADD COLUMN action_salt TEXT");if(enabled){db.prepare("UPDATE identity SET action_salt=? WHERE id=1 AND action_salt IS NULL").run(randomUUID());actionSalt=String(db.prepare("SELECT action_salt FROM identity WHERE id=1").get().action_salt)}db.exec("CREATE TABLE IF NOT EXISTS usage_export_seq(seq INTEGER PRIMARY KEY AUTOINCREMENT,event_id TEXT UNIQUE NOT NULL);CREATE TABLE IF NOT EXISTS collection_state(id INTEGER PRIMARY KEY CHECK(id=1),retained_events INTEGER NOT NULL,pruned_events INTEGER NOT NULL DEFAULT 0,retention_floor INTEGER NOT NULL DEFAULT 0,sequence_backfilled INTEGER NOT NULL DEFAULT 0);");if(!db.prepare("SELECT id FROM collection_state WHERE id=1").get())db.exec("INSERT INTO collection_state(id,retained_events) SELECT 1,COUNT(*) FROM usage;");if(!db.prepare("SELECT sequence_backfilled FROM collection_state WHERE id=1").get().sequence_backfilled){db.exec("INSERT OR IGNORE INTO usage_export_seq(event_id) SELECT id FROM usage ORDER BY at,id;UPDATE collection_state SET sequence_backfilled=1 WHERE id=1;")}db.exec("CREATE INDEX IF NOT EXISTS usage_at ON usage(at,id);CREATE UNIQUE INDEX IF NOT EXISTS usage_feedback_once ON usage(feedback_target,feedback_channel) WHERE feedback_target IS NOT NULL;CREATE UNIQUE INDEX IF NOT EXISTS usage_observation_once ON usage(observation_key) WHERE observation_key IS NOT NULL;CREATE INDEX IF NOT EXISTS usage_observation_scope ON usage(observation_scope,observation_recorded_at) WHERE observation_scope IS NOT NULL;CREATE INDEX IF NOT EXISTS usage_observation_budget ON usage(observation_recorded_at) WHERE observation_scope IS NOT NULL;CREATE TABLE IF NOT EXISTS observation_counters(id INTEGER PRIMARY KEY CHECK(id=1),rate_limited INTEGER NOT NULL DEFAULT 0,budget_limited INTEGER NOT NULL DEFAULT 0,unchanged INTEGER NOT NULL DEFAULT 0,duplicates INTEGER NOT NULL DEFAULT 0,last_suppressed_at TEXT);INSERT OR IGNORE INTO observation_counters(id) VALUES(1);CREATE TRIGGER IF NOT EXISTS usage_count_insert AFTER INSERT ON usage BEGIN UPDATE collection_state SET retained_events=retained_events+1 WHERE id=1;END;CREATE TRIGGER IF NOT EXISTS usage_count_delete AFTER DELETE ON usage BEGIN UPDATE collection_state SET retained_events=retained_events-1 WHERE id=1;END;COMMIT;PRAGMA busy_timeout=20;");initializing=false}catch(error){if(initializing){try{db.exec("ROLLBACK")}catch{}}db.close();throw error}const state=db.prepare("SELECT retained_events,pruned_events,retention_floor FROM collection_state WHERE id=1");const add=db.prepare("INSERT OR IGNORE INTO usage(id,at,operation,outcome,duration,source,code,internal,trace,metadata,feedback_target,feedback_channel) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)");const addSequence=db.prepare("INSERT INTO usage_export_seq(event_id) VALUES(?)");const byId=db.prepare("SELECT * FROM usage WHERE id=?");const byFeedback=db.prepare("SELECT * FROM usage WHERE feedback_target=? AND feedback_channel=?");const pageQuery=db.prepare("SELECT s.seq,u.* FROM usage_export_seq s JOIN usage u ON u.id=s.event_id WHERE s.seq>? ORDER BY s.seq LIMIT ?");const pruneFacts=db.prepare("SELECT COUNT(*) AS n,COALESCE(MAX(s.seq),0) AS last_seq FROM usage_export_seq s JOIN usage u ON u.id=s.event_id WHERE u.id IN (SELECT id FROM usage WHERE id<>? AND at<? ORDER BY at,id LIMIT ?)");const pruneSequences=db.prepare("DELETE FROM usage_export_seq WHERE event_id IN (SELECT id FROM usage WHERE id<>? AND at<? ORDER BY at,id LIMIT ?)");const pruneRows=db.prepare("DELETE FROM usage WHERE id IN (SELECT id FROM usage WHERE id<>? AND at<? ORDER BY at,id LIMIT ?)");const rememberPruning=db.prepare("UPDATE collection_state SET pruned_events=pruned_events+?,retention_floor=MAX(retention_floor,?) WHERE id=1");const oldest=db.prepare("SELECT MIN(at) AS at FROM usage WHERE id<>?");const observationByKey=db.prepare("SELECT id,observation_fingerprint FROM usage WHERE observation_key=?");const lastSnapshot=db.prepare("SELECT observation_fingerprint,observation_recorded_at FROM usage WHERE observation_scope=? ORDER BY observation_recorded_at DESC,id DESC LIMIT 1");const snapshotBudget=db.prepare("SELECT COUNT(*) AS n FROM usage WHERE observation_scope IS NOT NULL AND observation_recorded_at>=? AND observation_recorded_at<?");const observationMetadata=db.prepare("UPDATE usage SET observation_key=?,observation_fingerprint=?,observation_scope=?,observation_recorded_at=? WHERE id=?");const observationCounters=db.prepare("SELECT * FROM observation_counters WHERE id=1");const perform=async fn=>{if(closed)return businessError("unavailable","Telemetry is inactive.","storage");try{return fn()}catch(error){return businessError(error.errcode===5?"unavailable":"data_loss","Telemetry operation failed.","storage")}};const captureIdentity=enabled?{producerRef:randomUUID(),since:new Date(now()).toISOString()}:void 0;const captureCounts={attempted:0,accepted:0,suppressed:0,rejected:0,failed:0};const capture=async fn=>{if(!enabled||closed)return perform(fn);captureCounts.attempted++;const result=await perform(fn);if("ok"in result)captureCounts[result.ok.recorded?"accepted":"suppressed"]++;else if("err"in result&&["invalid_argument","already_exists"].includes(result.err.code))captureCounts.rejected++;else captureCounts.failed++;return result};function collection(after=0){const row=state.get(),stats=observationCounters.get();return{retainedEvents:Number(row.retained_events),prunedEvents:Number(row.pruned_events),retentionFloor:Number(row.retention_floor),limited:after<Number(row.retention_floor),retentionDays:TELEMETRY_RETENTION_DAYS,maxEvents:TELEMETRY_MAX_EVENTS,oldestAvailableAt:oldest.get(userId).at,observations:{snapshotRateLimited:Number(stats.rate_limited),snapshotBudgetLimited:Number(stats.budget_limited),snapshotUnchanged:Number(stats.unchanged),duplicates:Number(stats.duplicates),lastSuppressedAt:stats.last_suppressed_at}}}function decode(row){const metadata=row.metadata?JSON.parse(String(row.metadata)):{};return{id:String(row.id),at:String(row.at),operation:String(row.operation),outcome:String(row.outcome),durationMs:Number(row.duration),...row.source?{source:String(row.source)}:{},...row.code?{code:String(row.code)}:{},...row.internal?{internal:true}:{},...row.trace?{trace:JSON.parse(String(row.trace))}:{},...metadata}}function prune(cutoff,limit){const facts=pruneFacts.get(userId,cutoff,limit);if(!Number(facts.n))return;pruneSequences.run(userId,cutoff,limit);pruneRows.run(userId,cutoff,limit);rememberPruning.run(Number(facts.n),Number(facts.last_seq))}function maintain(){const now2=Date.now();if(now2>=nextAgeSweep){prune(new Date(now2-TELEMETRY_RETENTION_DAYS*DAY).toISOString(),2147483647);nextAgeSweep=now2+6e4}const excess=Number(state.get().retained_events)-TELEMETRY_MAX_EVENTS;if(excess>0)prune("9999-12-31T23:59:59.999Z",excess+Math.min(255,TELEMETRY_MAX_EVENTS-1))}function insert(event,id=randomUUID(),transaction=true,at=new Date().toISOString()){const execution=["product.resources","product.collection"].includes(event.operation)?void 0:currentOperationalExecution();const record={...event,id,at,...capturedContext?{context:capturedContext}:{},...execution?{execution}:{}};if(Buffer.byteLength(JSON.stringify(record))>TELEMETRY_MAX_RECORD_BYTES)throw Error("Telemetry record exceeds its closed metadata budget.");const metadata={...record.context?{context:record.context}:{},...record.execution?{execution:record.execution}:{},...event.operational?{operational:event.operational}:{},...event.resource?{resource:event.resource}:{},...event.collectionStatus?{collectionStatus:event.collectionStatus}:{},...event.result?{result:event.result}:{},...event.correlation?{correlation:event.correlation}:{},...event.errorCategory?{errorCategory:event.errorCategory}:{},...event.feedback?{feedback:event.feedback}:{},...event.observation?{observation:event.observation}:{},...event.invocation?{invocation:event.invocation}:{}};if(transaction)db.exec("BEGIN IMMEDIATE");try{const inserted=add.run(id,at,event.operation,event.outcome,event.durationMs,event.source??null,event.code??null,Number(event.internal??false),event.trace?JSON.stringify(event.trace):null,Object.keys(metadata).length?JSON.stringify(metadata):null,event.feedback?.targetReceiptId??null,event.feedback?.submissionChannel??null);if(Number(inserted.changes))addSequence.run(id);maintain();if(transaction)db.exec("COMMIT");return id}catch(error){if(transaction)db.exec("ROLLBACK");throw error}}if(enabled){try{db.exec("BEGIN IMMEDIATE");maintain();db.exec("COMMIT")}catch(error){try{db.exec("ROLLBACK")}catch{}db.close();throw error}}if(startup&&enabled){insert({operation:"product.first_start",outcome:"ok",durationMs:0,internal:true,code:created&&newInstallation?"new_install":"first_observed"},userId);insert({operation:"product.started",outcome:"ok",durationMs:0,internal:true})}const service={isEnabled:()=>enabled&&!closed,collectionStats:()=>!enabled||closed||!captureIdentity?void 0:{...captureIdentity,scope:"record_and_observe_api_calls",...captureCounts,pending:captureCounts.attempted-captureCounts.accepted-captureCounts.suppressed-captureCounts.rejected-captureCounts.failed},sourceReference(source){if(!enabled||closed||!actionSalt||typeof source!=="string"||!/^[a-z][a-z0-9-]{0,63}$/.test(source))return;const hash=createHmac("sha256",actionSalt).update(JSON.stringify(["zortex-source-v1",source])).digest("hex");return hash.slice(0,8)+"-"+hash.slice(8,12)+"-8"+hash.slice(13,16)+"-a"+hash.slice(17,20)+"-"+hash.slice(20,32)},actionReference(source,method){if(!enabled||closed||!actionSalt||typeof source!=="string"||!/^[a-z][a-z0-9-]{0,63}$/.test(source)||typeof method!=="string"||!method.length||Buffer.byteLength(method)>512)return;const hash=createHmac("sha256",actionSalt).update(JSON.stringify(["zortex-action-v2",source,method])).digest("hex");return hash.slice(0,8)+"-"+hash.slice(8,12)+"-8"+hash.slice(13,16)+"-a"+hash.slice(17,20)+"-"+hash.slice(20,32)},observe:input=>capture(()=>{if(!enabled)return ok({recorded:false,reason:"disabled"});const snapshot=snapshotUsageObservation(input);if(!isUsageObservation(snapshot))return businessError("invalid_argument","Observation accepts only fixed, content-free metadata and known counts.","storage");const{key,source,at,...rawFacts}=snapshot;const facts=Object.fromEntries(Object.entries(rawFacts).filter(([,value])=>value!==void 0));if(facts.kind==="connection")facts.capabilities=[...facts.capabilities].sort();const hash=value=>createHash("sha256").update(canonicalJson(value)).digest("hex");const observationKey=hash(["zortex-observation-v1",userId,snapshot.kind,source,key]);const fingerprint=hash({source,facts});const receiptId=observationKey.slice(0,8)+"-"+observationKey.slice(8,12)+"-5"+observationKey.slice(13,16)+"-a"+observationKey.slice(17,20)+"-"+observationKey.slice(20,32);const recordedAt=now(),observedAt=at??new Date(recordedAt).toISOString();const scope=facts.kind==="sync"?null:hash([facts.kind,source,facts.connectionRef??null,...facts.kind==="inventory"?[facts.population,facts.attribution]:[]]);db.exec("BEGIN IMMEDIATE");try{const prior=observationByKey.get(observationKey);if(prior){if(prior.observation_fingerprint!==fingerprint){db.exec("COMMIT");return businessError("already_exists","This observation key already has different metadata.","storage")}db.exec("UPDATE observation_counters SET duplicates=duplicates+1 WHERE id=1");db.exec("COMMIT");return ok({recorded:false,reason:"duplicate",receiptId:String(prior.id)})}if(scope){const previous=lastSnapshot.get(scope),elapsed=recordedAt-Number(previous?.observation_recorded_at??0);const unchanged=previous&&previous.observation_fingerprint===fingerprint&&elapsed<DAY;const limited=previous&&elapsed<OBSERVATION_SNAPSHOT_INTERVAL_MS;const dayStart=Math.floor(recordedAt/DAY)*DAY;const budget=Number(snapshotBudget.get(dayStart,dayStart+DAY).n)>=OBSERVATION_SNAPSHOT_DAILY_LIMIT;if(unchanged||limited||budget){const field=unchanged?"unchanged":limited?"rate_limited":"budget_limited";db.prepare(`UPDATE observation_counters SET ${field}=${field}+1,last_suppressed_at=? WHERE id=1`).run(new Date(recordedAt).toISOString());db.exec("COMMIT");return ok({recorded:false,reason:unchanged?"unchanged":"rate_limited"})}}const outcome=facts.kind!=="sync"?"ok":facts.status==="completed"?"ok":facts.status==="cancelled"?"cancelled":facts.status==="failed"||facts.status==="cleanup_blocked"?"fault":"unknown";insert({operation:"connector."+facts.kind,outcome,durationMs:facts.kind==="sync"?facts.durationMs:0,source,internal:true,observation:facts},receiptId,false,observedAt);observationMetadata.run(observationKey,fingerprint,scope,recordedAt,receiptId);db.exec("COMMIT");return ok({recorded:true,reason:"recorded",receiptId})}catch(error){db.exec("ROLLBACK");throw error}}),record:input=>capture(()=>{if(!enabled)return ok({recorded:false});const snapshot=snapshotUsageRecord(input);if(!isUsageEvent(snapshot)||snapshot.operation==="product.feedback"||snapshot.operation==="product.first_start")return businessError("invalid_argument","Usage accepts only content-free fields; startup and feedback anchors are provider-owned.","storage");const event=snapshot,flow=currentFeedbackFlow();if(!["product.resources","product.collection"].includes(event.operation)&&!event.correlation&&flow&&(!event.source||event.source===flow.source)&&isFlowId(flow.flowId))event.correlation={flowId:flow.flowId,...isFlowId(flow.connectionFlowId)?{connectionFlowId:flow.connectionFlowId}:{}};const invocation=["product.resources","product.collection"].includes(event.operation)?void 0:currentUsageInvocation();const measuredAt=event.resource?.asOf??event.collectionStatus?.asOf;return ok({recorded:true,receiptId:insert({...event,...invocation?{invocation:{...invocation}}:{}},void 0,true,measuredAt)})}),readBatch:({after=0,limit=500})=>perform(()=>{if(!Number.isSafeInteger(after)||after<0||!Number.isInteger(limit)||limit<1||limit>1e3)return businessError("invalid_argument","Usage paging needs an ordered cursor and 1\u20131000 events.","storage");const found=pageQuery.all(after,limit+1),selected=found.slice(0,limit);return ok({format:"zortex-usage/v1",userId,enabled,cursor:selected.length?Number(selected.at(-1).seq):after,more:found.length>limit,eventCursors:selected.map(row=>Number(row.seq)),events:selected.map(decode),collection:collection(after)})}),export:()=>perform(()=>{const events=db.prepare("SELECT * FROM usage ORDER BY at,id LIMIT 100001").all().map(decode);if(events.length>1e5)return businessError("resource_exhausted","Usage export exceeds its batch limit.","storage");return ok({format:"zortex-usage/v1",userId,enabled,events,collection:collection()})}),recent:({limit=5}={})=>perform(()=>{if(!Number.isInteger(limit)||limit<1||limit>20)return businessError("invalid_argument","Recent feedback needs a limit from 1 to 20.","storage");if(!enabled)return ok({enabled,events:[]});const rows=db.prepare("SELECT * FROM usage WHERE at>=? AND at<=? AND (operation IN ('search','context','sql','connector.read','connector.invoke') OR operation='action' AND code='effective_invoke') AND (internal=0 OR operation IN ('connector.read','connector.invoke')) ORDER BY at DESC,id DESC LIMIT ?").all(new Date(Date.now()-FEEDBACK_DAYS*DAY).toISOString(),new Date().toISOString(),limit);return ok({enabled,events:rows.map(row=>{const event=decode(row);return{receiptId:event.id,at:event.at,operation:event.operation,outcome:event.outcome,durationMs:event.durationMs,...event.source?{source:event.source}:{},...event.context?{context:event.context}:{},...event.result?{result:event.result}:{}}})})}),recordFeedback:(input,channel)=>perform(()=>{input={...input};channel={...channel};if(!isUsageFeedbackInput(input)||!channel||Object.keys(channel).some(key=>key!=="submissionChannel")||!FEEDBACK_CHANNELS.includes(channel.submissionChannel))return businessError("invalid_argument","Feedback needs one recent receipt, a fixed rating and an optional fixed reason.","storage");if(!enabled)return ok({recorded:false,delivery:"disabled"});db.exec("BEGIN IMMEDIATE");try{const prior=byFeedback.get(input.receiptId,channel.submissionChannel);if(prior){const feedback2=decode(prior).feedback;db.exec("COMMIT");return feedback2.rating===input.rating&&feedback2.reason===input.reason?ok({recorded:false,delivery:"queued",receiptId:String(prior.id)}):businessError("already_exists","This operation already has a different report through this channel.","storage")}const row=byId.get(input.receiptId);if(!row){db.exec("COMMIT");return businessError("not_found","The operation receipt is not available on this installation.","storage")}const target=decode(row),age=Date.now()-Date.parse(target.at);if(!feedbackEligible(target)||age<0||age>FEEDBACK_DAYS*DAY){db.exec("COMMIT");return businessError("failed_precondition","Feedback requires an eligible operation from the last seven days.","storage")}const feedback={targetReceiptId:target.id,rating:input.rating,...input.reason?{reason:input.reason}:{},submissionChannel:channel.submissionChannel,target:{operation:target.operation,outcome:target.outcome,at:target.at,...target.source?{source:target.source}:{},...target.context?{context:target.context}:{},...target.result?{result:target.result}:{}}};const receiptId=insert({operation:"product.feedback",outcome:"ok",durationMs:0,internal:true,feedback},randomUUID(),false);db.exec("COMMIT");return ok({recorded:true,delivery:"queued",receiptId})}catch(error){db.exec("ROLLBACK");throw error}}),report:()=>perform(()=>{const total=db.prepare("SELECT COUNT(*) AS calls,COALESCE(SUM(duration),0) AS duration FROM usage WHERE internal=0 AND operation NOT IN ('flywheel.start','flywheel.run','product.feedback')").get();const flywheel=db.prepare("SELECT COUNT(*) FILTER(WHERE operation='flywheel.start') AS started,COUNT(*) FILTER(WHERE operation='flywheel.run' AND outcome IN ('ok','empty')) AS completed,COUNT(*) FILTER(WHERE operation='flywheel.run' AND outcome='fault') AS failed FROM usage").get();const rows=db.prepare("SELECT source,COUNT(*) FILTER(WHERE outcome IN ('ok','empty','fault')) AS attempted,COUNT(*) FILTER(WHERE outcome='fault') AS faults,COUNT(*) FILTER(WHERE outcome='auth-blocked') AS authBlocked,COUNT(*) FILTER(WHERE outcome='cancelled') AS cancelled,COUNT(*) FILTER(WHERE outcome='invalid') AS invalid FROM usage WHERE operation IN ('connector.read','connector.invoke') AND source IS NOT NULL GROUP BY source ORDER BY source").all();const fabrication=db.prepare("SELECT source,COUNT(*) FILTER(WHERE outcome='ok') AS completed,COUNT(*) FILTER(WHERE outcome='fault') AS failed,COALESCE(SUM(duration),0) AS duration FROM usage WHERE operation='connector.fabricate' AND source IS NOT NULL GROUP BY source ORDER BY source").all();const usable=db.prepare("SELECT COUNT(*) AS n FROM usage_export_seq s JOIN usage u ON u.id=s.event_id WHERE u.operation='connector.usable' AND u.source IS NOT NULL AND u.outcome='ok' AND s.seq=(SELECT MAX(s2.seq) FROM usage_export_seq s2 JOIN usage u2 ON u2.id=s2.event_id WHERE u2.operation='connector.usable' AND u2.source=u.source)").get();return ok({enabled,userId,calls:Number(total.calls),durationMs:Number(total.duration),flywheel:{started:Number(flywheel.started),completed:Number(flywheel.completed),failed:Number(flywheel.failed)},connectors:rows.map(row=>({source:String(row.source),attempted:Number(row.attempted),faults:Number(row.faults),faultRate:Number(row.attempted)?Number(row.faults)/Number(row.attempted):null,authBlocked:Number(row.authBlocked),cancelled:Number(row.cancelled),invalid:Number(row.invalid)})),fabrication:fabrication.map(row=>({source:String(row.source),completed:Number(row.completed),failed:Number(row.failed),durationMs:Number(row.duration)})),usableConnectors:Number(usable.n),collection:collection()})}),async close(){if(!closed){closed=true;db.close()}}};return service}export async function apply(ctx,config){const freshRoot=process.env.ZORTEX_TELEMETRY_NEW_INSTALL_ROOT;const newInstallation=config.newInstallation??!!(freshRoot&&isAbsolute(freshRoot)&&typeof config.root==="string"&&resolve(freshRoot)===resolve(config.root));const service=await createTelemetry({...config,newInstallation,startup:config.startup??true});ctx.provide("zortexTelemetry",service);ctx.effect(()=>()=>service.close())}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zortexhq/indra-v2.5",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -9,7 +9,7 @@
9
9
  "tag": "next"
10
10
  },
11
11
  "type": "module",
12
- "description": "Zortex daily 2026-11-21 (source 0.2.0)",
12
+ "description": "Zortex daily 2026-11-22 (source 0.2.0)",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "https://github.com/ZortexHQ/indra-v2.git",
@@ -1027,9 +1027,9 @@
1027
1027
  "zortexRelease": {
1028
1028
  "schemaVersion": 1,
1029
1029
  "sourceVersion": "0.2.0",
1030
- "sourceSha": "0e20bc0a76239a6e5f6262a7a8128e55992acbc9",
1031
- "sourceDate": "2026-11-21T17:32:06.000Z",
1032
- "version": "0.2.3"
1030
+ "sourceSha": "5378d58afdd11c924198abfdfcae1ee2902a8a29",
1031
+ "sourceDate": "2026-11-22T10:26:40.000Z",
1032
+ "version": "0.2.4"
1033
1033
  },
1034
1034
  "zortex": {
1035
1035
  "role": "app"
@@ -1040,6 +1040,6 @@
1040
1040
  "zortexUpdate": {
1041
1041
  "schemaVersion": 1,
1042
1042
  "manifest": "update-manifest.json",
1043
- "sha256": "a62cda7439d165001861d44650d520d05b08a6528a9a7f502fa9dbff7a3d9548"
1043
+ "sha256": "126d983115180389af0d191fbc12859bc902bd643dc0fb372b1795d6a7ed565c"
1044
1044
  }
1045
1045
  }
package/profiles/core.yml CHANGED
@@ -2,6 +2,7 @@
2
2
  name: '@zortexhq/plugin-telemetry'
3
3
  config:
4
4
  root: !!js "process.env.ZORTEX_ENGINE_ROOT + '/metrics'"
5
+ deviceIdentityFile: !!js "process.env.ZORTEX_DEVICE_IDENTITY_FILE || undefined"
5
6
  enabled: !!js "!/^(0|false|off|no)$/i.test((process.env.ZORTEX_TELEMETRY || '').trim()) && !/^(1|true|yes)$/i.test((process.env.DO_NOT_TRACK || '').trim())"
6
7
  - id: indra-product-account
7
8
  name: '@zortexhq/plugin-product-account'
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 3,
3
3
  "name": "@zortexhq/indra-v2.5",
4
- "version": "0.2.3",
4
+ "version": "0.2.4",
5
5
  "platforms": [
6
6
  "win32-x64",
7
7
  "win32-arm64",
@@ -15,16 +15,16 @@
15
15
  "sharp"
16
16
  ]
17
17
  },
18
- "commit": "0e20bc0a76239a6e5f6262a7a8128e55992acbc9",
18
+ "commit": "5378d58afdd11c924198abfdfcae1ee2902a8a29",
19
19
  "lockSha256": "9c6259007f2ecd65db9911ad5d7a151e87cd2d0c79d4d901ede2dd40ae9f4053",
20
20
  "platform": "linux",
21
21
  "arch": "x64",
22
22
  "zortexRelease": {
23
23
  "schemaVersion": 1,
24
24
  "sourceVersion": "0.2.0",
25
- "sourceSha": "0e20bc0a76239a6e5f6262a7a8128e55992acbc9",
26
- "sourceDate": "2026-11-21T17:32:06.000Z",
27
- "version": "0.2.3"
25
+ "sourceSha": "5378d58afdd11c924198abfdfcae1ee2902a8a29",
26
+ "sourceDate": "2026-11-22T10:26:40.000Z",
27
+ "version": "0.2.4"
28
28
  },
29
29
  "npm": {
30
30
  "externalDependencies": {
@@ -907,10 +907,10 @@
907
907
  "packages": [
908
908
  {
909
909
  "name": "@zortexhq/indra-v2.5",
910
- "version": "0.2.3",
910
+ "version": "0.2.4",
911
911
  "target": "",
912
912
  "fileCount": 135,
913
- "filesSha256": "6fad563212f3aa1cba949103179853554150a0d41ad3a907a13827dc5e2432f1"
913
+ "filesSha256": "e58635cf28aabfd5387fad3a78645ebbc4eb6b7b08f942823e7173235705170e"
914
914
  },
915
915
  {
916
916
  "name": "@abd-enterprises/zendesk-mcp",
@@ -1154,8 +1154,8 @@
1154
1154
  "name": "@zortexhq/plugin-galaxy-ui",
1155
1155
  "version": "0.1.0",
1156
1156
  "target": "node_modules/@zortexhq/plugin-galaxy-ui",
1157
- "fileCount": 196,
1158
- "filesSha256": "1a87a07782d8c053cbd79a9a934aa1816ec61cb0d37f8609c637311815e80582"
1157
+ "fileCount": 198,
1158
+ "filesSha256": "9eb92d3c04c9f72f3d86a63e1f56b422015a3215ef343c7a27cbfe9cb5d7af58"
1159
1159
  },
1160
1160
  {
1161
1161
  "name": "@zortexhq/plugin-google-auth",
@@ -1196,8 +1196,8 @@
1196
1196
  "name": "@zortexhq/plugin-posthog",
1197
1197
  "version": "0.1.0",
1198
1198
  "target": "node_modules/@zortexhq/plugin-posthog",
1199
- "fileCount": 17,
1200
- "filesSha256": "eb64fb686b1ad2aeaebec1abf6a59e89cdb4a56c15742958639215d24e5cf0e7"
1199
+ "fileCount": 18,
1200
+ "filesSha256": "d30211b8648f02ee8e167153773eccdaf2bcee99239e8d622e4f86a6fd5e0fad"
1201
1201
  },
1202
1202
  {
1203
1203
  "name": "@zortexhq/plugin-process-local",
@@ -1217,8 +1217,8 @@
1217
1217
  "name": "@zortexhq/plugin-telemetry",
1218
1218
  "version": "0.1.0",
1219
1219
  "target": "node_modules/@zortexhq/plugin-telemetry",
1220
- "fileCount": 16,
1221
- "filesSha256": "8d762234b883c426638dd5e63ce36ec885f2cad88496b3dc4bb6e0184ddcaa29"
1220
+ "fileCount": 17,
1221
+ "filesSha256": "c11dbb4192103fa09bdbb34277683677344b6dafc039dc15331def17e8364cca"
1222
1222
  },
1223
1223
  {
1224
1224
  "name": "@zortexhq/plugin-tunnel-frp",
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "package": {
4
4
  "name": "@zortexhq/indra-v2.5",
5
- "version": "0.2.3",
5
+ "version": "0.2.4",
6
6
  "private": false,
7
7
  "license": "UNLICENSED",
8
8
  "publishConfig": {
@@ -11,7 +11,7 @@
11
11
  "tag": "next"
12
12
  },
13
13
  "type": "module",
14
- "description": "Zortex daily 2026-11-21 (source 0.2.0)",
14
+ "description": "Zortex daily 2026-11-22 (source 0.2.0)",
15
15
  "repository": {
16
16
  "type": "git",
17
17
  "url": "https://github.com/ZortexHQ/indra-v2.git",
@@ -1029,9 +1029,9 @@
1029
1029
  "zortexRelease": {
1030
1030
  "schemaVersion": 1,
1031
1031
  "sourceVersion": "0.2.0",
1032
- "sourceSha": "0e20bc0a76239a6e5f6262a7a8128e55992acbc9",
1033
- "sourceDate": "2026-11-21T17:32:06.000Z",
1034
- "version": "0.2.3"
1032
+ "sourceSha": "5378d58afdd11c924198abfdfcae1ee2902a8a29",
1033
+ "sourceDate": "2026-11-22T10:26:40.000Z",
1034
+ "version": "0.2.4"
1035
1035
  },
1036
1036
  "zortex": {
1037
1037
  "role": "app"
@@ -1043,7 +1043,7 @@
1043
1043
  "provenance": {
1044
1044
  "schemaVersion": 3,
1045
1045
  "name": "@zortexhq/indra-v2.5",
1046
- "version": "0.2.3",
1046
+ "version": "0.2.4",
1047
1047
  "platforms": [
1048
1048
  "win32-x64",
1049
1049
  "win32-arm64",
@@ -1057,16 +1057,16 @@
1057
1057
  "sharp"
1058
1058
  ]
1059
1059
  },
1060
- "commit": "0e20bc0a76239a6e5f6262a7a8128e55992acbc9",
1060
+ "commit": "5378d58afdd11c924198abfdfcae1ee2902a8a29",
1061
1061
  "lockSha256": "9c6259007f2ecd65db9911ad5d7a151e87cd2d0c79d4d901ede2dd40ae9f4053",
1062
1062
  "platform": "linux",
1063
1063
  "arch": "x64",
1064
1064
  "zortexRelease": {
1065
1065
  "schemaVersion": 1,
1066
1066
  "sourceVersion": "0.2.0",
1067
- "sourceSha": "0e20bc0a76239a6e5f6262a7a8128e55992acbc9",
1068
- "sourceDate": "2026-11-21T17:32:06.000Z",
1069
- "version": "0.2.3"
1067
+ "sourceSha": "5378d58afdd11c924198abfdfcae1ee2902a8a29",
1068
+ "sourceDate": "2026-11-22T10:26:40.000Z",
1069
+ "version": "0.2.4"
1070
1070
  },
1071
1071
  "npm": {
1072
1072
  "externalDependencies": {
@@ -1949,7 +1949,7 @@
1949
1949
  "packages": [
1950
1950
  {
1951
1951
  "name": "@zortexhq/indra-v2.5",
1952
- "version": "0.2.3",
1952
+ "version": "0.2.4",
1953
1953
  "target": "",
1954
1954
  "fileCount": 135,
1955
1955
  "filesSha256": null
@@ -2196,8 +2196,8 @@
2196
2196
  "name": "@zortexhq/plugin-galaxy-ui",
2197
2197
  "version": "0.1.0",
2198
2198
  "target": "node_modules/@zortexhq/plugin-galaxy-ui",
2199
- "fileCount": 196,
2200
- "filesSha256": "1a87a07782d8c053cbd79a9a934aa1816ec61cb0d37f8609c637311815e80582"
2199
+ "fileCount": 198,
2200
+ "filesSha256": "9eb92d3c04c9f72f3d86a63e1f56b422015a3215ef343c7a27cbfe9cb5d7af58"
2201
2201
  },
2202
2202
  {
2203
2203
  "name": "@zortexhq/plugin-google-auth",
@@ -2238,8 +2238,8 @@
2238
2238
  "name": "@zortexhq/plugin-posthog",
2239
2239
  "version": "0.1.0",
2240
2240
  "target": "node_modules/@zortexhq/plugin-posthog",
2241
- "fileCount": 17,
2242
- "filesSha256": "eb64fb686b1ad2aeaebec1abf6a59e89cdb4a56c15742958639215d24e5cf0e7"
2241
+ "fileCount": 18,
2242
+ "filesSha256": "d30211b8648f02ee8e167153773eccdaf2bcee99239e8d622e4f86a6fd5e0fad"
2243
2243
  },
2244
2244
  {
2245
2245
  "name": "@zortexhq/plugin-process-local",
@@ -2259,8 +2259,8 @@
2259
2259
  "name": "@zortexhq/plugin-telemetry",
2260
2260
  "version": "0.1.0",
2261
2261
  "target": "node_modules/@zortexhq/plugin-telemetry",
2262
- "fileCount": 16,
2263
- "filesSha256": "8d762234b883c426638dd5e63ce36ec885f2cad88496b3dc4bb6e0184ddcaa29"
2262
+ "fileCount": 17,
2263
+ "filesSha256": "c11dbb4192103fa09bdbb34277683677344b6dafc039dc15331def17e8364cca"
2264
2264
  },
2265
2265
  {
2266
2266
  "name": "@zortexhq/plugin-tunnel-frp",
@@ -2705,8 +2705,8 @@
2705
2705
  },
2706
2706
  {
2707
2707
  "path": "dist/measurement-context.js",
2708
- "sha256": "e738ba14d419011ffc17a565e6dbff8b6a6842e5659480450f7a463f67e294c0",
2709
- "size": 672,
2708
+ "sha256": "ccee7239af36b1c180cbb1e2790c0c960d77b6fe8435dd2bfe6c2dca7f0f9a78",
2709
+ "size": 1083,
2710
2710
  "mode": 420
2711
2711
  },
2712
2712
  {
@@ -2777,8 +2777,8 @@
2777
2777
  },
2778
2778
  {
2779
2779
  "path": "dist/product-feedback.js",
2780
- "sha256": "47b60ee2ef6c58fba76fa420f146efb36d6376454ff23b6ffbe68b45e638dcf1",
2781
- "size": 5582,
2780
+ "sha256": "0d8342d7ad4fda17b1d75b32770d0a56e1acfe81648c85211d17e6a5f1d4be44",
2781
+ "size": 5655,
2782
2782
  "mode": 420
2783
2783
  },
2784
2784
  {
@@ -2795,8 +2795,8 @@
2795
2795
  },
2796
2796
  {
2797
2797
  "path": "dist/profile.js",
2798
- "sha256": "eccf7cdcbef6d247c1255232353cdadb15deee1e3e86f5d4baf4fdbc4fb650a3",
2799
- "size": 3761,
2798
+ "sha256": "8668bc8dcbb77e7def028fa82b01ab415b4d170f6ffcfc463babe27c44391adb",
2799
+ "size": 3855,
2800
2800
  "mode": 420
2801
2801
  },
2802
2802
  {
@@ -10433,8 +10433,8 @@
10433
10433
  },
10434
10434
  {
10435
10435
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/dist/galaxy-text.js",
10436
- "sha256": "7ef9a32fd9061811c7b9296e78cacc77e4a656d1fcf8a84627746ae84be9a6bb",
10437
- "size": 105944,
10436
+ "sha256": "00156c7920cdf082473a4dc3d55bc755a180913b46f93abd512356ff805ede09",
10437
+ "size": 103549,
10438
10438
  "mode": 420
10439
10439
  },
10440
10440
  {
@@ -10445,8 +10445,8 @@
10445
10445
  },
10446
10446
  {
10447
10447
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/dist/localizer.js",
10448
- "sha256": "2cfab3cbc96870f179165ae42091a809d7e634cd256694c6b34b9df647b0855b",
10449
- "size": 3900,
10448
+ "sha256": "3018194502f7bebbfa36f5535c0da31459ceb8cc51b3958d0d61e98592513cf9",
10449
+ "size": 3966,
10450
10450
  "mode": 420
10451
10451
  },
10452
10452
  {
@@ -10481,8 +10481,8 @@
10481
10481
  },
10482
10482
  {
10483
10483
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/dist/routes.js",
10484
- "sha256": "f2a7445e98d4c36eeac6bf8c3f6fef57620b191058ab459deb1d272b1f2e3707",
10485
- "size": 12284,
10484
+ "sha256": "87dda41770367dc12af4d81feebce1b448d67f84081a2bc63452a4bd1b152f5c",
10485
+ "size": 11344,
10486
10486
  "mode": 420
10487
10487
  },
10488
10488
  {
@@ -10517,38 +10517,38 @@
10517
10517
  },
10518
10518
  {
10519
10519
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/account.js",
10520
- "sha256": "1d7bdc2ed9d594f4a2ff40430574a04bec8443f2ee1274256aafb034b4100f7d",
10521
- "size": 5046,
10520
+ "sha256": "3be41b320ca7bfff59711c58b6d00fc17d61f629d236940ede3a40f0b941f84d",
10521
+ "size": 6790,
10522
10522
  "mode": 420
10523
10523
  },
10524
10524
  {
10525
- "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-catalog.js",
10526
- "sha256": "901f2bb9d5de9613bc81b21aae73c13b6ec9db12756776041bf66ffd50458efe",
10527
- "size": 4033,
10525
+ "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-i18n-twin.js",
10526
+ "sha256": "47a0f2615001b7066db26e4da20bd009c9f7371dd488ea9fd35d8b4ee8c271f1",
10527
+ "size": 157141,
10528
10528
  "mode": 420
10529
10529
  },
10530
10530
  {
10531
10531
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-i18n.js",
10532
- "sha256": "62d48d6675addcfa423b9c26699c4202f6ad3e5e4f96f6b9a52db467689f9815",
10533
- "size": 158409,
10532
+ "sha256": "0cbaf42497ab0ee439f23f8f06f793eb33c2267c943170938f6ab7c339f483f3",
10533
+ "size": 157108,
10534
10534
  "mode": 420
10535
10535
  },
10536
10536
  {
10537
10537
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-model.js",
10538
- "sha256": "06533364942f362dad7641b6cc57e0ddc363e3c569969f2c3fe02f42b55c208e",
10539
- "size": 7342,
10538
+ "sha256": "a6132e61d4fb7c2e5765e0e7260472802238691e9ff9a0c2e0cde969318c290b",
10539
+ "size": 7341,
10540
10540
  "mode": 420
10541
10541
  },
10542
10542
  {
10543
10543
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app-text.js",
10544
- "sha256": "3513714f8125488850794b62e9866c0b5ec09ff9ca03dc0dcceaecb738af7336",
10545
- "size": 49032,
10544
+ "sha256": "f6bf670fb168e6a86d8ecfad622ec859d7149861dbfe8709496b95bab8242e38",
10545
+ "size": 51024,
10546
10546
  "mode": 420
10547
10547
  },
10548
10548
  {
10549
10549
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/app.html",
10550
- "sha256": "863943ddf944f764d87eecd3c60852430eae7948ac72e924cfcf1e069012456f",
10551
- "size": 5434,
10550
+ "sha256": "f53100a3c2cd2c70d3e8a2ffc40fe12f64d926c7c8269f60e45fc86c9197ea66",
10551
+ "size": 7611,
10552
10552
  "mode": 420
10553
10553
  },
10554
10554
  {
@@ -10564,27 +10564,39 @@
10564
10564
  "mode": 420
10565
10565
  },
10566
10566
  {
10567
- "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/demo.js",
10568
- "sha256": "ac8053846502572b732be26a4048f7e733e96f725d00cc0e98d4dacfbc7e0793",
10569
- "size": 4419,
10567
+ "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/connection-panel.js",
10568
+ "sha256": "ece4b19461758c992ada961116886a5af2949bd61aa74e5100a39f9740edea0c",
10569
+ "size": 15303,
10570
+ "mode": 420
10571
+ },
10572
+ {
10573
+ "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/galaxy-renderer.js",
10574
+ "sha256": "a73f21d2102f38568f23c01eafc6b059ad008ebd1eb246563dc5b5dabab533d8",
10575
+ "size": 67783,
10576
+ "mode": 420
10577
+ },
10578
+ {
10579
+ "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/galaxy.html",
10580
+ "sha256": "174b5684ff40370767de6a025adc9e8283a3e1189ab4b6c4b936c49c2e14ef6f",
10581
+ "size": 11294,
10570
10582
  "mode": 420
10571
10583
  },
10572
10584
  {
10573
10585
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/live-model.js",
10574
- "sha256": "c423af51457886d7266930e8adf4fa03d48a6ef89f0a3dcfe9d80fff4bd563f9",
10575
- "size": 2121,
10586
+ "sha256": "fd5c2b0f255334bec6d54f4586b1fa50636735fd03254ceefe0e339f72c81c0a",
10587
+ "size": 3116,
10576
10588
  "mode": 420
10577
10589
  },
10578
10590
  {
10579
10591
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/live-state.js",
10580
- "sha256": "d75bbcb06a0c25c8e4cfc996cfa06c81e7e14fac87c933c8792a8a35a72c7ad7",
10581
- "size": 395,
10592
+ "sha256": "fed04639031a14d75781228cb1f0bd87ea2ad7c363fd90576e14b5a1e3f4acc5",
10593
+ "size": 437,
10582
10594
  "mode": 420
10583
10595
  },
10584
10596
  {
10585
10597
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/panels-live.js",
10586
- "sha256": "cb87e861db3b2a520582613c3c023685ac0ea14328e7d051589f382990ab3431",
10587
- "size": 16909,
10598
+ "sha256": "41427a95659378738f460c9d8c17b15d995190b798c7f0aac0f57694ca790341",
10599
+ "size": 17241,
10588
10600
  "mode": 420
10589
10601
  },
10590
10602
  {
@@ -10601,8 +10613,8 @@
10601
10613
  },
10602
10614
  {
10603
10615
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/product.js",
10604
- "sha256": "2ea4968895f4376807551ee38a7b272442665480bd00ac97c171b71db34ad0eb",
10605
- "size": 4302,
10616
+ "sha256": "749849cb46d5cf95194a2ded12195c3579e8facd975cf63b0e4f857713fe36a0",
10617
+ "size": 4340,
10606
10618
  "mode": 420
10607
10619
  },
10608
10620
  {
@@ -10613,14 +10625,14 @@
10613
10625
  },
10614
10626
  {
10615
10627
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/shell.css",
10616
- "sha256": "f57ca092a4d68d5d9804b208d3cf06fea1b42486401bcbd8b35f2721639eab61",
10617
- "size": 26761,
10628
+ "sha256": "303a911b77262988b7ee9d5846a59853a2a6668f8770bf89a5855ee70cf10f2c",
10629
+ "size": 2306,
10618
10630
  "mode": 420
10619
10631
  },
10620
10632
  {
10621
10633
  "path": "node_modules/@zortexhq/plugin-galaxy-ui/src/integration/shell.js",
10622
- "sha256": "4809c35c8556e3352997127ee081c50832507b1903b209fcf9defd46ed71a54f",
10623
- "size": 40894,
10634
+ "sha256": "88cd6cd70dbf407785d405fd560fd38ded2ab6388df5d0f148799919dfb3ce34",
10635
+ "size": 14577,
10624
10636
  "mode": 420
10625
10637
  },
10626
10638
  {
@@ -11985,6 +11997,12 @@
11985
11997
  "size": 336,
11986
11998
  "mode": 420
11987
11999
  },
12000
+ {
12001
+ "path": "node_modules/@zortexhq/plugin-posthog/dist/activity.js",
12002
+ "sha256": "8240c6b3f57d8402918293c19d00b7233af36b2aa79ec61832964f38ec31d94c",
12003
+ "size": 3234,
12004
+ "mode": 420
12005
+ },
11988
12006
  {
11989
12007
  "path": "node_modules/@zortexhq/plugin-posthog/dist/collection-gap.js",
11990
12008
  "sha256": "81b826ca588bcce06245c258cb1ebb9960a04583ddcc3b00abcd9aa86430444a",
@@ -12035,8 +12053,8 @@
12035
12053
  },
12036
12054
  {
12037
12055
  "path": "node_modules/@zortexhq/plugin-posthog/dist/northstar.js",
12038
- "sha256": "9676ed8945653fe2fc4bf437e32c61215dc3a605f4aa405548cf064f54baccf4",
12039
- "size": 16376,
12056
+ "sha256": "858944b5fb98b09bfa7dbd4175524bd0fed47357233b864ee504e3667ae6f6ce",
12057
+ "size": 17897,
12040
12058
  "mode": 420
12041
12059
  },
12042
12060
  {
@@ -12155,8 +12173,8 @@
12155
12173
  },
12156
12174
  {
12157
12175
  "path": "node_modules/@zortexhq/plugin-telemetry/dist/api/measurement.js",
12158
- "sha256": "0520d4391658415cbd969ca2f0ee24161a97f40b35b64b98dc189593bfab7dc8",
12159
- "size": 9081,
12176
+ "sha256": "e92891cb1c602a9035b3848b15422d5f12ac2921194f592fd665e6cfb6182f70",
12177
+ "size": 9247,
12160
12178
  "mode": 420
12161
12179
  },
12162
12180
  {
@@ -12185,8 +12203,8 @@
12185
12203
  },
12186
12204
  {
12187
12205
  "path": "node_modules/@zortexhq/plugin-telemetry/dist/api/telemetry.js",
12188
- "sha256": "029a84cce73c1d1902f03eafccacc76270eea7e4a68489ab43adfc83961c2c57",
12189
- "size": 3470,
12206
+ "sha256": "660102620beab3bd4648d6eda731434193a40e6bfd06205f9f87126291cfa633",
12207
+ "size": 3781,
12190
12208
  "mode": 420
12191
12209
  },
12192
12210
  {
@@ -12213,10 +12231,16 @@
12213
12231
  "size": 1406,
12214
12232
  "mode": 420
12215
12233
  },
12234
+ {
12235
+ "path": "node_modules/@zortexhq/plugin-telemetry/dist/device-identity.js",
12236
+ "sha256": "dc2abd99590044fa8ffbda8f728c5f7c09b290b603ca884c0f587cd27eaf6828",
12237
+ "size": 2120,
12238
+ "mode": 420
12239
+ },
12216
12240
  {
12217
12241
  "path": "node_modules/@zortexhq/plugin-telemetry/dist/index.js",
12218
- "sha256": "a30a74d51ce3cd106f65fa1362c93479afd333f08f0f7b150bdfc503fba4b85d",
12219
- "size": 23219,
12242
+ "sha256": "569f1be67edbc73b06b29a31fd9729c5157c6be9ef98cf7ee87ad6446c2b2215",
12243
+ "size": 23521,
12220
12244
  "mode": 420
12221
12245
  },
12222
12246
  {
@@ -21695,8 +21719,8 @@
21695
21719
  },
21696
21720
  {
21697
21721
  "path": "profiles/core.yml",
21698
- "sha256": "fc3ca8b3e9e0f38d5313d3aa0e1419e7136b4d5ed4d3a446abf569494ba57ac9",
21699
- "size": 4484,
21722
+ "sha256": "5aa17478d00e97e0aba80629ff6bb559c0019b3525245f68cdddd0020c038703",
21723
+ "size": 4568,
21700
21724
  "mode": 420
21701
21725
  },
21702
21726
  {
@@ -1 +0,0 @@
1
- const entries={gmail:["Gmail","Email","Email, conversations, and the context behind them.","gmail"],"google-drive":["Google Drive","Productivity","Keep your files and documents within reach.","google-drive"],"google-calendar":["Google Calendar","Productivity","Make room for what\u2019s next.","google-calendar"],slack:["Slack","Messaging","Bring your team\u2019s conversations together.","slack"],notion:["Notion","Productivity","Your notes, projects, and knowledge in one place.","notion"],"whatsapp-web":["WhatsApp","Messaging","Connect the conversations that matter to you.","whatsapp-web"],whatsapp:["WhatsApp","Messaging","Connect the conversations that matter to you.","whatsapp-web"],github:["GitHub","Developer tools","Keep your code and project context close.","github"],linear:["Linear","Developer tools","A clear view of your team\u2019s projects.","linear"],figma:["Figma","Design","Bring design context into your workspace.","figma"],"google-chrome":["Google Chrome","On your computer","Connect your browsing history from this computer.","google-chrome"],"microsoft-edge":["Microsoft Edge","On your computer","Connect your browsing history from this computer.","microsoft-edge"],obsidian:["Obsidian","Productivity","Give your local notes a place in your workspace.","obsidian"],"computer-files":["Computer files","On your computer","Connect the folders you choose.","computer-files"],outlook:["Outlook","Email","Your email and everyday work, connected.","outlook"],"apple-notes":["Apple Notes","On your computer","Make your saved thoughts easy to find.","apple-reminders"],chatgpt:["ChatGPT","AI","Bring your AI conversations into one place.","chatgpt"],"google-contacts":["Google Contacts","Productivity","Connect the people in your address book.","google-contacts"],"google-chat":["Google Chat","Messaging","Keep up with your team\u2019s conversations.","google-chat"],youtube:["YouTube","Media","Bring your video activity into view.","youtube"],spotify:["Spotify","Media","Connect the music in your day.","spotify"],discord:["Discord","Messaging","Connect your communities and conversations.","discord"],telegram:["Telegram","Messaging","Keep your conversations connected.","telegram"],joplin:["Joplin","Productivity","Connect your notes with a secure local pairing.","joplin"],zotero:["Zotero","Productivity","Bring your research library together.","zotero"],dropbox:["Dropbox","Productivity","Keep your files connected to your work.","dropbox"],box:["Box","Productivity","Bring your shared files into view.","box"],nextcloud:["Nextcloud","Productivity","Connect your own cloud.","nextcloud"],wechat:["WeChat","Messaging","Connect your personal conversations.","wechat"],"proton-mail":["Proton Mail","Email","Connect mail through your local Bridge.","proton-mail"],thunderbird:["Thunderbird","Email","Connect mail from your computer.","thunderbird"],"microsoft-teams":["Microsoft Teams","Messaging","Bring your team\u2019s work together.","teams"]};export function appIdentity(source,provided={}){const item=entries[source];const name=item?.[0]||(provided.label||(provided.name!==source?provided.name:null))||source.split("-").map(word=>word.charAt(0).toUpperCase()+word.slice(1)).join(" ");return{name,category:item?.[1]||"More apps",description:item?.[2]||`Connect ${name} to your workspace.`,icon:item?.[3]||source}}export const featuredApps=["google-drive","slack","notion"];export const lightMonochromeIconPaths=new Set(["basecamp","box","calcom","calendly","chatgpt","confluence","dropbox","facebook","freshrss","ghost","github","immich","instagram","jira","joplin","karakeep","linkedin","matrix","mattermost","microsoft-edge","miro","nextcloud","notebooklm","notion","obsidian","posthog","railway","sentry","steam","tiktok","trello","wakatime","wallabag","webflow","wordpress","x","youtube","zendesk","zoom","zotero"].map(id=>"icons/local/"+id+".svg"));export const modCatalog=[{id:"galaxy",name:"Galaxy",category:"Included",description:"See the shape of your connected context.",kind:"mod",icon:"galaxy"}];
@@ -1 +0,0 @@
1
- import{appIdentity}from"./app-catalog.js";export function createDemoWorkspace(){const ids=["gmail","google-drive","slack","notion","whatsapp-web","google-calendar","github","linear","figma","obsidian","google-chrome","dropbox"];const records={gmail:1248,"google-drive":842,slack:0,notion:0,"whatsapp-web":0,"google-calendar":56,github:0,linear:0,figma:0,obsidian:0,"google-chrome":316};const scenarios=new Map([["gmail","success"],["google-drive","success"],["slack","failure"],["notion","empty"],["whatsapp-web","qr"],["google-calendar","success"],["google-chrome","success"],["obsidian","setup"]]);function row(source){const scenario=scenarios.get(source)||"disconnected";const base={source,label:appIdentity(source).name,connection:"not-connected",state:"pending",read:"not-attempted",support:{state:"supported"},demoScenario:scenario};if(scenario==="success")return{...base,connection:"connected",state:"complete",read:"first-record",returned:12,availability:"read",operation:"succeeded"};if(scenario==="empty")return{...base,connection:"connected",state:"empty",read:"empty",returned:0,availability:"read",operation:"succeeded"};if(scenario==="actions")return{...base,connection:"connected",state:"actions-ready",read:"not-attempted",availability:"actions",actions:18,operation:"not-run"};if(scenario==="failure")return{...base,state:"failed",errorCode:"login_required",message:"Automatic connection could not finish."};if(scenario==="revoked")return{...base,state:"failed",errorCode:"authorization_expired"};if(scenario==="outage")return{...base,connection:"connected",state:"failed",errorCode:"provider_unavailable"};if(scenario==="expired")return{...base,state:"failed",errorCode:"qr_expired",message:"The QR code has expired."};if(scenario==="qr")return{...base,state:"waiting-user",authorizationImage:{mimeType:"image/png",data:"demo-only"}};if(scenario==="waiting")return{...base,state:"waiting-user"};if(scenario==="working")return{...base,state:"connecting"};if(scenario==="setup")return{...base,state:"pending",setupAvailable:true,support:{state:"setup-required"}};if(scenario==="unavailable")return{...base,state:"unavailable",connection:"unavailable",support:{state:"unsupported",message:"This app needs the desktop runtime."}};return base}const report=()=>({state:"partial",success:false,sources:ids.map(row),others:[]});const snapshot=()=>({status:"demo",productVersion:"Demo",generatedAt:new Date().toISOString(),totalItems:2462,inventory:{label:"Sample workspace",storedRecords:2462},coverage:ids.map(source=>({source,registered:true,configured:true,items:records[source]||0,connectionState:row(source).connection,dataState:records[source]?"has_records":"empty_unverified",support:row(source).support}))});return{read:async()=>({snapshot:snapshot(),report:report(),abilities:{apps:ids.map(id=>({id,name:appIdentity(id).name})),localIconPaths:Object.fromEntries(ids.filter(id=>id!=="slack").map(id=>[id,`icons/local/${appIdentity(id).icon}.svg`])),iconSources:{slack:"m"},iconAliases:{}}}),request:async input=>{if(!input||typeof input.action!=="string")throw Error("Choose an action.");if(input.action==="status")return report();if(!ids.includes(input.source))throw Error("Choose an app in this demo.");const source=input.source;if(input.action==="cancel")scenarios.set(source,"disconnected");else if(input.action==="demo-complete"||input.action==="read")scenarios.set(source,records[source]?"success":"empty");else if(input.action==="connect"||input.action==="authorize"||input.action==="reconnect-saved")scenarios.set(source,source==="whatsapp-web"?"qr":"waiting");else if(input.action.startsWith("configure-"))scenarios.set(source,"disconnected");else if(input.action==="discover-native-vault")return{candidates:[{path:"/Users/demo/Notes",label:"Sample notes folder"}]};else throw Error("This action is not part of the demo.");return report()},preview(source,scenario){if(ids.includes(source))scenarios.set(source,scenario)},scenario(source){return scenarios.get(source)||"disconnected"}}}export const demoScenarios=[["success","Connected"],["empty","Connected, no items"],["actions","Actions ready"],["failure","Automatic setup failed"],["qr","QR code"],["expired","QR expired"],["waiting","Waiting for sign-in"],["working","Connecting"],["revoked","Reconnect needed"],["outage","Temporary failure"],["setup","Manual setup"],["unavailable","Requires desktop"],["disconnected","Not connected"]];