tinet-agent-cli 0.1.0.dev36__py3-none-any.whl

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 (104) hide show
  1. taco/__init__.py +1 -0
  2. taco/agent_openapi/__init__.py +1 -0
  3. taco/agent_openapi/catalog.py +198 -0
  4. taco/agent_openapi/models.py +47 -0
  5. taco/agent_openapi/parameters.py +111 -0
  6. taco/agent_openapi/service.py +73 -0
  7. taco/aikb/__init__.py +4 -0
  8. taco/aikb/catalog.py +380 -0
  9. taco/aikb/executors.py +157 -0
  10. taco/aikb/file_input.py +55 -0
  11. taco/aikb/models.py +42 -0
  12. taco/aikb/parameters.py +135 -0
  13. taco/aikb/service.py +68 -0
  14. taco/assets/__init__.py +1 -0
  15. taco/assets/agent_openapi/catalog.json +14 -0
  16. taco/assets/agent_openapi/operations/conversation/list-conversations.json +67 -0
  17. taco/assets/agent_openapi/operations/message/list-conversation-messages.json +80 -0
  18. taco/assets/agent_openapi/operations/trace/list-message-traces.json +72 -0
  19. taco/assets/aikb/catalog.json +41 -0
  20. taco/assets/aikb/operations/conversation/chat-conversation-on-open.json +99 -0
  21. taco/assets/aikb/operations/directory/delete-directory.json +81 -0
  22. taco/assets/aikb/operations/directory/edit-directory.json +97 -0
  23. taco/assets/aikb/operations/directory/list-directory-tree.json +106 -0
  24. taco/assets/aikb/operations/directory/save-directory.json +109 -0
  25. taco/assets/aikb/operations/faq/create-faq.json +193 -0
  26. taco/assets/aikb/operations/faq/delete-faq.json +81 -0
  27. taco/assets/aikb/operations/faq/describe-faq.json +82 -0
  28. taco/assets/aikb/operations/faq/edit-faq.json +193 -0
  29. taco/assets/aikb/operations/faq/list-faqs.json +136 -0
  30. taco/assets/aikb/operations/file/create-file.json +145 -0
  31. taco/assets/aikb/operations/file/delete-files.json +110 -0
  32. taco/assets/aikb/operations/file/describe-file.json +82 -0
  33. taco/assets/aikb/operations/file/get-file-upload-url.json +154 -0
  34. taco/assets/aikb/operations/file/list-files.json +146 -0
  35. taco/assets/aikb/operations/media/describe-faq-media-url.json +98 -0
  36. taco/assets/aikb/operations/media/describe-file-media-url.json +90 -0
  37. taco/assets/aikb/operations/oss/signature-for-upload.json +85 -0
  38. taco/assets/aikb/operations/recycle-bin/list-recycled-items.json +151 -0
  39. taco/assets/aikb/operations/repository/describe-bot-repository.json +71 -0
  40. taco/assets/aikb/operations/repository/list-private-repositories.json +75 -0
  41. taco/assets/aikb/operations/repository/list-public-repositories.json +75 -0
  42. taco/assets/aikb/operations/search/search-knowledge-on-open.json +180 -0
  43. taco/assets/examples/README.md +3 -0
  44. taco/assets/examples/agent-basic.json +16 -0
  45. taco/assets/examples/agent-builtin-tool.json +28 -0
  46. taco/assets/examples/agent-workflow-tool.json +30 -0
  47. taco/assets/examples/chatflow-basic.json +24 -0
  48. taco/assets/examples/workflow-http.json +34 -0
  49. taco/assets/manifest.json +12 -0
  50. taco/assets/scenarios/README.md +3 -0
  51. taco/assets/scenarios/agent-basic.json +80 -0
  52. taco/assets/scenarios/agent-builtin-tool.json +116 -0
  53. taco/assets/scenarios/agent-workflow-tool.json +277 -0
  54. taco/assets/schemas/README.md +3 -0
  55. taco/assets/schemas/agent-tool.json +71 -0
  56. taco/assets/schemas/agent.json +199 -0
  57. taco/assets/schemas/chatflow.json +1048 -0
  58. taco/assets/schemas/workflow.http.json +1052 -0
  59. taco/assets/schemas/workflow.json +1052 -0
  60. taco/assets/skills/README.md +3 -0
  61. taco/assets/skills/taco/SKILL.md +68 -0
  62. taco/assets/skills/taco/manifest.json +10 -0
  63. taco/cli.py +127 -0
  64. taco/commands/__init__.py +1 -0
  65. taco/commands/agent.py +760 -0
  66. taco/commands/aikb.py +132 -0
  67. taco/commands/app.py +151 -0
  68. taco/commands/category.py +37 -0
  69. taco/commands/chatflow.py +183 -0
  70. taco/commands/credential.py +222 -0
  71. taco/commands/discovery.py +409 -0
  72. taco/commands/model.py +55 -0
  73. taco/commands/profile.py +124 -0
  74. taco/commands/tool.py +61 -0
  75. taco/commands/workflow.py +714 -0
  76. taco/core/__init__.py +1 -0
  77. taco/core/access_token_manager.py +98 -0
  78. taco/core/api_client.py +263 -0
  79. taco/core/assets.py +81 -0
  80. taco/core/config_store.py +209 -0
  81. taco/core/context.py +19 -0
  82. taco/core/developer_center_client.py +165 -0
  83. taco/core/errors.py +19 -0
  84. taco/core/file_lock.py +80 -0
  85. taco/core/http_headers.py +21 -0
  86. taco/core/openapi_signer.py +221 -0
  87. taco/core/output.py +72 -0
  88. taco/core/profile_manager.py +217 -0
  89. taco/core/profile_resolver.py +151 -0
  90. taco/core/secure_file.py +76 -0
  91. taco/release.py +363 -0
  92. taco/services/__init__.py +1 -0
  93. taco/services/agent_service.py +314 -0
  94. taco/services/app_service.py +153 -0
  95. taco/services/category_service.py +57 -0
  96. taco/services/model_service.py +117 -0
  97. taco/services/tool_service.py +482 -0
  98. taco/services/workflow_compiler.py +1665 -0
  99. taco/services/workflow_service.py +652 -0
  100. taco/services/workflow_tool_service.py +439 -0
  101. tinet_agent_cli-0.1.0.dev36.dist-info/METADATA +158 -0
  102. tinet_agent_cli-0.1.0.dev36.dist-info/RECORD +104 -0
  103. tinet_agent_cli-0.1.0.dev36.dist-info/WHEEL +4 -0
  104. tinet_agent_cli-0.1.0.dev36.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,124 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from typing import Any
5
+
6
+ import typer
7
+
8
+ from taco.core.context import get_cli_context
9
+ from taco.core.errors import TacoError
10
+ from taco.core.output import emit_success, exit_with_error
11
+ from taco.core.profile_manager import ProfileManager
12
+
13
+
14
+ profile_app = typer.Typer(help="查看 Zenava/TACO profile,并管理 TACO profile")
15
+
16
+
17
+ @profile_app.command("set", help="创建或修改 profile,并切换为当前 profile。")
18
+ def set_profile(
19
+ ctx: typer.Context,
20
+ name: str = typer.Option(..., "--name", help="唯一 profile 名称。"),
21
+ endpoint: str = typer.Option(..., "--endpoint", help="开发者中心平台根地址。"),
22
+ access_key_id: str = typer.Option(..., "--access-key-id", help="AccessKeyId。"),
23
+ access_key_secret: str | None = typer.Option(
24
+ None,
25
+ "--access-key-secret",
26
+ help="AccessKeySecret;自动化环境推荐使用 TACO_ACCESS_KEY_SECRET。",
27
+ ),
28
+ ) -> None:
29
+ cli_context = get_cli_context(ctx)
30
+ secret = access_key_secret or os.getenv("TACO_ACCESS_KEY_SECRET")
31
+ if not secret and not cli_context.no_input:
32
+ secret = typer.prompt("AccessKeySecret", hide_input=True)
33
+ if not secret:
34
+ exit_with_error(
35
+ ctx,
36
+ TacoError(
37
+ code="ACCESS_KEY_SECRET_REQUIRED",
38
+ message="缺少 AccessKeySecret。",
39
+ exit_code=2,
40
+ hint="请传入 --access-key-secret,或设置 TACO_ACCESS_KEY_SECRET。",
41
+ ),
42
+ )
43
+ try:
44
+ result = ProfileManager().set_profile(
45
+ name=name,
46
+ endpoint=endpoint,
47
+ access_key_id=access_key_id,
48
+ access_key_secret=secret,
49
+ )
50
+ except TacoError as error:
51
+ exit_with_error(ctx, error)
52
+ emit_success(ctx, result, human_message=f"已保存并切换到 profile `{name}`。")
53
+
54
+
55
+ @profile_app.command("list", help="列出 Zenava 和 TACO 的全部 profile 及当前状态。")
56
+ def list_profiles(ctx: typer.Context) -> None:
57
+ try:
58
+ result = ProfileManager().list_profiles()
59
+ except TacoError as error:
60
+ exit_with_error(ctx, error)
61
+ emit_success(ctx, result, human_message=_format_list(result))
62
+
63
+
64
+ @profile_app.command("use", help="切换当前 TACO profile。")
65
+ def use(ctx: typer.Context, profile: str = typer.Argument(...)) -> None:
66
+ try:
67
+ result = ProfileManager().use(profile)
68
+ except TacoError as error:
69
+ exit_with_error(ctx, error)
70
+ emit_success(ctx, result, human_message=f"当前 profile 已切换为 `{profile}`。")
71
+
72
+
73
+ @profile_app.command("delete", help="删除指定 TACO profile。")
74
+ def delete(
75
+ ctx: typer.Context,
76
+ profile: str = typer.Argument(...),
77
+ yes: bool = typer.Option(False, "--yes", help="确认删除 profile。"),
78
+ ) -> None:
79
+ cli_context = get_cli_context(ctx)
80
+ if not yes:
81
+ if cli_context.no_input:
82
+ exit_with_error(
83
+ ctx,
84
+ TacoError(
85
+ code="PROFILE_DELETE_CONFIRM_REQUIRED",
86
+ message="删除 profile 前必须显式确认。",
87
+ exit_code=2,
88
+ hint=f"确认后执行 taco profile delete {profile} --yes。",
89
+ ),
90
+ )
91
+ if not typer.confirm(f"确认删除 profile `{profile}`?"):
92
+ raise typer.Abort()
93
+ try:
94
+ result = ProfileManager().delete(profile)
95
+ except TacoError as error:
96
+ exit_with_error(ctx, error)
97
+ emit_success(ctx, result, human_message=f"已删除 profile `{profile}`。")
98
+
99
+
100
+ def _format_list(profiles: list[dict[str, Any]]) -> str:
101
+ if not profiles:
102
+ return "尚未找到 Zenava 或 TACO profile。"
103
+ columns = (
104
+ ("CURRENT", "current"),
105
+ ("SOURCE", "source"),
106
+ ("KEY", "key"),
107
+ ("ENDPOINT", "endpoint"),
108
+ ("ACCESS-KEY-ID", "access_key_id"),
109
+ ("ACCESS-KEY-SECRET", "access_key_secret"),
110
+ ("ACCESS-TOKEN", "access_token"),
111
+ ("ACCESS-TOKEN-UPDATED-AT", "access_token_updated_at"),
112
+ )
113
+ rows = [
114
+ ["*" if item["current"] else "", *(str(item[key]) or "-" for _, key in columns[1:])]
115
+ for item in profiles
116
+ ]
117
+ widths = [
118
+ max(len(title), *(len(row[index]) for row in rows))
119
+ for index, (title, _) in enumerate(columns)
120
+ ]
121
+ header = " ".join(title.ljust(widths[index]) for index, (title, _) in enumerate(columns))
122
+ separator = " ".join("-" * width for width in widths)
123
+ body = [" ".join(value.ljust(widths[index]) for index, value in enumerate(row)) for row in rows]
124
+ return "\n".join([header, separator, *body])
taco/commands/tool.py ADDED
@@ -0,0 +1,61 @@
1
+ from __future__ import annotations
2
+
3
+ import typer
4
+
5
+ from taco.core.context import get_cli_context
6
+ from taco.core.errors import TacoError
7
+ from taco.core.output import emit_success, exit_with_error
8
+ from taco.services.tool_service import ToolService
9
+
10
+
11
+ tool_app = typer.Typer(help="内置工具发现")
12
+ tool_provider_app = typer.Typer(help="工具 Provider 发现")
13
+ tool_app.add_typer(tool_provider_app, name="provider")
14
+
15
+
16
+ @tool_provider_app.command("list", help="列出 builtin/plugin 工具 Provider。")
17
+ def list_tool_providers(ctx: typer.Context) -> None:
18
+ cli_context = get_cli_context(ctx)
19
+ try:
20
+ result = ToolService().list_providers(profile=cli_context.profile)
21
+ except TacoError as error:
22
+ exit_with_error(ctx, error, json_default=True)
23
+ emit_success(ctx, result, json_default=True)
24
+
25
+
26
+ @tool_app.command("list", help="列出内置工具,可按 Provider 过滤。")
27
+ def list_tools(
28
+ ctx: typer.Context,
29
+ provider: str | None = typer.Option(
30
+ None,
31
+ "--provider",
32
+ help="完整 Provider ID。",
33
+ ),
34
+ ) -> None:
35
+ cli_context = get_cli_context(ctx)
36
+ try:
37
+ result = ToolService().list_tools(
38
+ provider=provider,
39
+ profile=cli_context.profile,
40
+ )
41
+ except TacoError as error:
42
+ exit_with_error(ctx, error, json_default=True)
43
+ emit_success(ctx, result, json_default=True)
44
+
45
+
46
+ @tool_app.command("describe", help="读取工具参数与 Provider 凭据 schema。")
47
+ def describe_tool(
48
+ ctx: typer.Context,
49
+ provider: str = typer.Option(..., "--provider", help="完整 Provider ID。"),
50
+ tool: str = typer.Option(..., "--tool", help="工具 action 名称。"),
51
+ ) -> None:
52
+ cli_context = get_cli_context(ctx)
53
+ try:
54
+ result = ToolService().describe_tool(
55
+ provider=provider,
56
+ tool=tool,
57
+ profile=cli_context.profile,
58
+ )
59
+ except TacoError as error:
60
+ exit_with_error(ctx, error, json_default=True)
61
+ emit_success(ctx, result, json_default=True)