Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
'use strict';
// Offline TOP contracts from frozen official getDocument field trees and wire examples.
const fs=require('node:fs'),path=require('node:path'),crypto=require('node:crypto');
const evidence=JSON.parse(fs.readFileSync(path.resolve(__dirname,'../test/fixtures/connectors/official-contracts/taobao-20261001.json'),'utf8'));
const cleanType=s=>s.replaceAll(' ','');
function object(fields,row){const properties={},required=[];for(const f of fields){if(Object.hasOwn(properties,f.name))throw Error('Duplicate input field');properties[f.name]=field(f,row);if(f.required)required.push(f.name);}return{type:'object',properties,additionalProperties:false,...(required.length?{required}:{})};}
function scalar(type){if(type==='Number')return{anyOf:[{type:'integer',minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER},{type:'string',pattern:'^(0|-?[1-9][0-9]*)$',maxLength:20}],'x-top-number':true};if(type==='Boolean')return{type:'boolean'};if(['String','Date','Price'].includes(type))return{type:'string',maxLength:262144,...(type==='Price'?{pattern:'^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$'}:{})};throw Error('Unreviewed input scalar '+type);}
function field(f,row){const t=cleanType(f.type),array=t.endsWith('[]');let s;if(array)s={type:'array',items:f.children.length?object(f.children,row):scalar(t.slice(0,-2)),maxItems:Math.min(Number(f.maxListSize)>0?Number(f.maxListSize):Infinity,row.risk==='R'?100:row.risk==='W'?25:10)};else if(f.children.length)s=object(f.children,row);else if(t==='Json')s={type:'object',maxProperties:row.risk==='R'?100:10,additionalProperties:true};else s=scalar(t);
if(row.doc_id===69204&&f.name==='sku_map')s={type:'object',propertyNames:{pattern:'^[1-9][0-9]{0,18}$'},additionalProperties:{type:'integer',enum:[1,-2]},minProperties:1,maxProperties:10};
if(s.type==='string'&&Number(f.maxLength)>0)s.maxLength=Math.min(s.maxLength,Number(f.maxLength));
s.description=f.description;if(f.binding)s['x-binding']=f.binding;
if(t==='Number'){for(const[k,target]of [['minValue','x-min'],['maxValue','x-max']])if(f[k]!==undefined){if(!/^-?[0-9]+$/.test(String(f[k])))throw Error('Noninteger Number bound requires review');s[target]=String(f[k]);}
if(['page_size','pageSize','page_size_num','pageSizeNum','limit'].includes(f.name)){s['x-min']=s['x-min']||'1';s['x-max']=String(Math.min(Number(s['x-max']||100),100));s.description+=' Host page limit: '+s['x-max']+'. Request subsequent pages explicitly.';}}
if(array)s.description+=' Host batch limit: '+s.maxItems+'.';return s;}
function output(fields){return fields.map(f=>{const t=cleanType(f.type),array=t.endsWith('[]'),base=array?t.slice(0,-2):t;const n={name:f.name,type:base,array,children:output(f.children),...(f.alternative?{alternative:f.alternative}:{})};
if(['success','is_success','request_success','success_flag','cancel_success','apply_success','wl_success','res_success','sub_success','query_success','is_delete_success'].includes(f.name)&&['Boolean','String'].includes(base)||base==='Boolean'&&/是否成功|取消是否成功|true.*成功.*false.*失败/.test(f.description))n.success_flag=true;
if(['error','failure'].includes(f.name)&&base==='Boolean')n.failure_flag=true;
if(['error_codes','error_code_list','fail_item_ids','failed_mail_order_unique_key_list'].includes(f.name))n.failure_list=true;
if(f.name==='failure_count')n.failure_count=true;
if(['message','msg','error_msg','error_message','error_desc','error_info','one_error_info','sub_error_msg','biz_error_msg','biz_error_message','wl_error_msg','res_error_msg','call_error_msg','fail_info','fail_reason','failure_reason','mapped_error_messages','failed_mail_order_reason_map','error_info_list'].includes(f.name)&&['String','String[]'].includes(t)&&/错误|失败|异常|error|Error|系统自动生成|返回信息/.test(f.description))n.diagnostic=true;
if(f.type==='Number'&&/0为成功/.test(f.description)||f.type==='String'&&/0:表示查询成功/.test(f.description))n.success_codes=['0'];
return n;});}
const methods={};for(const r of evidence.normalized_contracts){if(!/^[a-z][A-Za-z0-9]*(\.[A-Za-z0-9]+)+$/.test(r.method)||methods[r.method])throw Error('Invalid fixed method');const billed=r.labels.some(x=>x.includes('¥')&&!x.includes('免费'));
methods[r.method]={method:r.method,doc_id:r.doc_id,risk:r.risk,description:r.title+(billed?' [Provider-billed API]':''),documentation_url:r.source_url,source_sha256:r.source_sha256,seller_types:r.seller_types,requirements:{billing:{provider_billed:billed,official_labels:r.labels},permission_packages:r.permission_packages.map(x=>x.name),authorization:'The approved application must hold the documented API package and the seller must have the required product entitlement. Seller type alone does not prove permission.'},input_schema:object(r.input_fields,r),wire_fields:r.input_fields.map(f=>({name:f.name,type:cleanType(f.type),structured:f.children.length>0})),output_tree:output(r.output_fields),response_wrapper:r.response_wrapper,...(r.selectable_fields?{selectable_fields:r.selectable_fields}:{})};}
const source_hash=crypto.createHash('sha256').update(JSON.stringify(evidence.normalized_contracts)).digest('hex');const text="'use strict';\n// Generated by scripts/generate-taobao-api-contracts.cjs; do not edit.\nmodule.exports="+JSON.stringify({source_hash,methods})+';\n';fs.writeFileSync(process.argv[2]?path.resolve(process.argv[2]):path.resolve(__dirname,'../bin/taobao-api-contracts.cjs'),text);console.log(JSON.stringify({methods:Object.keys(methods).length,source_hash,bytes:Buffer.byteLength(text)}));